Sha256: 7a09f82fc47035c475796852413871b7bc91144c4549ae548d3a2f9440fa8f84

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 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: "#{quoted_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

1 entries across 1 versions & 1 rubygems

Version Path
spree_core-2.0.13 app/models/spree/product_property.rb