mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-10 21:24:20 +01:00
(bug) product slug isn't unique
This commit is contained in:
parent
1aa058f3d6
commit
ded9b4a1e8
@ -20,6 +20,7 @@ class Product < ApplicationRecord
|
|||||||
accepts_nested_attributes_for :product_stock_movements, allow_destroy: true, reject_if: :all_blank
|
accepts_nested_attributes_for :product_stock_movements, allow_destroy: true, reject_if: :all_blank
|
||||||
|
|
||||||
validates :name, :slug, presence: true
|
validates :name, :slug, presence: true
|
||||||
|
validates :slug, uniqueness: true
|
||||||
validates :amount, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
|
validates :amount, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
|
||||||
|
|
||||||
scope :active, -> { where(is_active: true) }
|
scope :active, -> { where(is_active: true) }
|
||||||
|
@ -7,6 +7,7 @@ class ProductCategory < ApplicationRecord
|
|||||||
friendly_id :name, use: :slugged
|
friendly_id :name, use: :slugged
|
||||||
|
|
||||||
validates :name, :slug, presence: true
|
validates :name, :slug, presence: true
|
||||||
|
validates :slug, uniqueness: true
|
||||||
|
|
||||||
belongs_to :parent, class_name: 'ProductCategory'
|
belongs_to :parent, class_name: 'ProductCategory'
|
||||||
has_many :children, class_name: 'ProductCategory', foreign_key: :parent_id
|
has_many :children, class_name: 'ProductCategory', foreign_key: :parent_id
|
||||||
|
Loading…
Reference in New Issue
Block a user