mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
15 lines
517 B
Ruby
15 lines
517 B
Ruby
class InventoryItem < ActiveRecord::Base
|
|
attr_accessible :enterprise, :enterprise_id, :variant, :variant_id, :visible
|
|
|
|
belongs_to :enterprise
|
|
belongs_to :variant, class_name: "Spree::Variant"
|
|
|
|
validates :variant_id, uniqueness: { scope: :enterprise_id }
|
|
validates :enterprise_id, presence: true
|
|
validates :variant_id, presence: true
|
|
validates :visible, inclusion: { in: [true, false], message: "must be true or false" }
|
|
|
|
scope :visible, where(visible: true)
|
|
scope :hidden, where(visible: false)
|
|
end
|