Sha256: c1b4760c6b81a2350adbac249584c69bb6a33904c777aea8f8e312d8ff6b5156

Contents?: true

Size: 741 Bytes

Versions: 14

Compression:

Stored size: 741 Bytes

Contents

module Spree
  class ProductProperty < ActiveRecord::Base
    belongs_to :product, class_name: 'Spree::Product'
    belongs_to :property, class_name: 'Spree::Property'

    validates :property, presence: true
    validates :value, length: { maximum: 255 }

    attr_accessible :property_name, :value, :position

    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

14 entries across 14 versions & 1 rubygems

Version Path
spree_core-2.0.12 app/models/spree/product_property.rb
spree_core-2.0.11 app/models/spree/product_property.rb
spree_core-2.0.10 app/models/spree/product_property.rb
spree_core-2.0.9 app/models/spree/product_property.rb
spree_core-2.0.8 app/models/spree/product_property.rb
spree_core-2.0.7 app/models/spree/product_property.rb
spree_core-2.0.6 app/models/spree/product_property.rb
spree_core-2.0.5 app/models/spree/product_property.rb
spree_core-2.0.4 app/models/spree/product_property.rb
spree_core-2.0.3 app/models/spree/product_property.rb
spree_core-2.0.2 app/models/spree/product_property.rb
spree_core-2.0.1 app/models/spree/product_property.rb
spree_core-2.0.0 app/models/spree/product_property.rb
spree_core-2.0.0.rc1 app/models/spree/product_property.rb