Sha256: 8db7a06534fb768bcf18fc17b1651cf37e3372475bf0e0127fdb18dc82d66a3a
Contents?: true
Size: 801 Bytes
Versions: 36
Compression:
Stored size: 801 Bytes
Contents
module Spree class OptionValue < Spree::Base belongs_to :option_type, class_name: 'Spree::OptionType', touch: true, inverse_of: :option_values acts_as_list scope: :option_type has_many :option_value_variants, class_name: 'Spree::OptionValueVariant' has_many :variants, through: :option_value_variants, class_name: 'Spree::Variant' with_options presence: true do validates :name, uniqueness: { scope: :option_type_id, allow_blank: true } validates :presentation end after_touch :touch_all_variants delegate :name, :presentation, to: :option_type, prefix: true, allow_nil: true self.whitelisted_ransackable_attributes = ['presentation'] private def touch_all_variants variants.update_all(updated_at: Time.current) end end end
Version data entries
36 entries across 36 versions & 2 rubygems