mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
add products relation in product's category
This commit is contained in:
parent
272cbf165c
commit
19e3921dc4
@ -7,4 +7,6 @@ class Product < ApplicationRecord
|
|||||||
has_and_belongs_to_many :machines
|
has_and_belongs_to_many :machines
|
||||||
|
|
||||||
validates_numericality_of :amount, greater_than: 0, allow_nil: true
|
validates_numericality_of :amount, greater_than: 0, allow_nil: true
|
||||||
|
|
||||||
|
scope :active, -> { where(is_active: true) }
|
||||||
end
|
end
|
||||||
|
@ -8,5 +8,7 @@ class ProductCategory < ApplicationRecord
|
|||||||
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
|
||||||
|
|
||||||
|
has_many :products
|
||||||
|
|
||||||
acts_as_list scope: :parent, top_of_list: 0
|
acts_as_list scope: :parent, top_of_list: 0
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user