Sha256: d96acdcf86f71f6ec2fee5f4d94a26165ebab4ba4763c6bb64116a9b958d1144
Contents?: true
Size: 698 Bytes
Versions: 9
Compression:
Stored size: 698 Bytes
Contents
module Spree class OptionType < ActiveRecord::Base has_many :option_values, -> { order(:position) }, dependent: :destroy has_many :product_option_types, dependent: :destroy has_many :products, through: :product_option_types has_and_belongs_to_many :prototypes, join_table: 'spree_option_types_prototypes' validates :name, :presentation, presence: true default_scope -> { order("#{self.table_name}.position") } accepts_nested_attributes_for :option_values, reject_if: lambda { |ov| ov[:name].blank? || ov[:presentation].blank? }, allow_destroy: true after_touch :touch_all_products def touch_all_products products.find_each(&:touch) end end end
Version data entries
9 entries across 9 versions & 1 rubygems