Sha256: 1188483b666001577a1884115cfeeb41e71bf06cf113debf74a24a9c5b7eabda

Contents?: true

Size: 665 Bytes

Versions: 9

Compression:

Stored size: 665 Bytes

Contents

module Spree
  class OptionValue < ActiveRecord::Base
    belongs_to :option_type, :class_name => 'Spree::OptionType', :touch => true
    acts_as_list scope: :option_type
    has_and_belongs_to_many :variants, join_table: 'spree_option_values_variants', class_name: "Spree::Variant"

    validates :name, :presentation, presence: true

    after_touch :touch_all_variants

    def touch_all_variants
      # This can cause a cascade of products to be updated
      # To disable it in Rails 4.1, we can do this:
      # https://github.com/rails/rails/pull/12772
      # Spree::Product.no_touching do
        variants.find_each(&:touch)
      # end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spree_core-2.1.12 app/models/spree/option_value.rb
spree_core-2.1.11 app/models/spree/option_value.rb
spree_core-2.1.10 app/models/spree/option_value.rb
spree_core-2.1.9 app/models/spree/option_value.rb
spree_core-2.1.8 app/models/spree/option_value.rb
spree_core-2.1.7 app/models/spree/option_value.rb
spree_core-2.1.6 app/models/spree/option_value.rb
spree_core-2.1.5 app/models/spree/option_value.rb
spree_core-2.1.4 app/models/spree/option_value.rb