Files
openfoodnetwork/app/models/inventory_item.rb
Luis Ramos e52937c113 Use rubocop auto correct to add frozen string literal to all files
This is an unsafe auto corection, we will need to trust our build here
2021-06-17 23:07:26 +01:00

16 lines
504 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 :enterprise, presence: true
validates :variant, presence: true
validates :visible,
inclusion: { in: [true, false], message: I18n.t(:inventory_item_visibility_error) }
scope :visible, -> { where(visible: true) }
scope :hidden, -> { where(visible: false) }
end