Sha256: 2b2b38efbd40a6d7617b462d940dc6c34b6d8f75b0805e535e6211f20d3d10cf

Contents?: true

Size: 637 Bytes

Versions: 6

Compression:

Stored size: 637 Bytes

Contents

module Spree
  class Property < ActiveRecord::Base
    has_and_belongs_to_many :prototypes, join_table: 'spree_properties_prototypes'

    has_many :product_properties, dependent: :destroy
    has_many :products, through: :product_properties

    attr_accessible :name, :presentation

    validates :name, :presentation, presence: true

    scope :sorted, -> { order(:name) }

    def self.find_all_by_prototype(prototype)
      id = prototype
      id = prototype.id if prototype.class == Prototype
      joins("LEFT JOIN properties_prototypes ON property_id = #{self.table_name}.id").
        where(prototype_id: id)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spree_core-2.0.4 app/models/spree/property.rb
spree_core-2.0.3 app/models/spree/property.rb
spree_core-2.0.2 app/models/spree/property.rb
spree_core-2.0.1 app/models/spree/property.rb
spree_core-2.0.0 app/models/spree/property.rb
spree_core-2.0.0.rc1 app/models/spree/property.rb