mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
- presence: true is redundant since Rails 5.0 BUT applies with new default config of belongs_to_required_by_default to true Lots of files with belongs_to_required_by_default = false (backward compatibility) So: deleting this setting implies to adding optional: true - added 'NOT NULL' constraints so model constraints match with contraints on DB tables. - updated the todo
14 lines
427 B
Ruby
14 lines
427 B
Ruby
# frozen_string_literal: true
|
|
|
|
class InventoryItem < ApplicationRecord
|
|
belongs_to :enterprise
|
|
belongs_to :variant, class_name: "Spree::Variant"
|
|
|
|
validates :variant_id, uniqueness: { scope: :enterprise_id }
|
|
validates :visible,
|
|
inclusion: { in: [true, false], message: I18n.t(:inventory_item_visibility_error) }
|
|
|
|
scope :visible, -> { where(visible: true) }
|
|
scope :hidden, -> { where(visible: false) }
|
|
end
|