Sha256: 497ae465ae6f5bf03755133a88706d84129bca6ca0f0fdb2b0ad0f20bf7d880b
Contents?: true
Size: 796 Bytes
Versions: 4
Compression:
Stored size: 796 Bytes
Contents
module Spree class ProductProperty < Spree::Base belongs_to :product, touch: true, class_name: 'Spree::Product', inverse_of: :product_properties belongs_to :property, class_name: 'Spree::Property', inverse_of: :product_properties validates :property, presence: true validates_with Spree::Validations::DbMaximumLengthValidator, field: :value default_scope { order("#{self.table_name}.position") } # virtual attributes for use with AJAX completion stuff def property_name property.name if property end def property_name=(name) unless name.blank? unless property = Property.find_by(name: name) property = Property.create(name: name, presentation: name) end self.property = property end end end end
Version data entries
4 entries across 4 versions & 1 rubygems