1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00

(bug) product slug isn't unique

This commit is contained in:
Du Peng 2022-09-19 19:31:43 +02:00
parent 1aa058f3d6
commit ded9b4a1e8
2 changed files with 2 additions and 0 deletions

View File

@ -20,6 +20,7 @@ class Product < ApplicationRecord
accepts_nested_attributes_for :product_stock_movements, allow_destroy: true, reject_if: :all_blank
validates :name, :slug, presence: true
validates :slug, uniqueness: true
validates :amount, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
scope :active, -> { where(is_active: true) }

View File

@ -7,6 +7,7 @@ class ProductCategory < ApplicationRecord
friendly_id :name, use: :slugged
validates :name, :slug, presence: true
validates :slug, uniqueness: true
belongs_to :parent, class_name: 'ProductCategory'
has_many :children, class_name: 'ProductCategory', foreign_key: :parent_id