Sha256: 9a8340905403dc0ba24c350274ee7e0db6a27811279722ef9b29aaffb3c25884
Contents?: true
Size: 890 Bytes
Versions: 42
Compression:
Stored size: 890 Bytes
Contents
module Spree class ProductProperty < Spree::Base acts_as_list scope: :product with_options inverse_of: :product_properties do belongs_to :product, touch: true, class_name: 'Spree::Product' belongs_to :property, class_name: 'Spree::Property' end validates :property, presence: true validates :value, db_maximum_length: true default_scope { order(:position) } self.whitelisted_ransackable_attributes = ['value'] self.whitelisted_ransackable_associations = ['property'] # virtual attributes for use with AJAX completion stuff delegate :name, to: :property, prefix: true, allow_nil: true def property_name=(name) if name.present? # don't use `find_by :name` to workaround globalize/globalize#423 bug self.property = Property.where(name: name).first_or_create(presentation: name) end end end end
Version data entries
42 entries across 42 versions & 1 rubygems