Sha256: c3c0073f908cd8074b1376d9a814f265722056e35a8371067f61cfa9a776a9de

Contents?: true

Size: 640 Bytes

Versions: 8

Compression:

Stored size: 640 Bytes

Contents

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

    has_many :product_properties, dependent: :delete_all
    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

8 entries across 8 versions & 1 rubygems

Version Path
spree_core-2.0.12 app/models/spree/property.rb
spree_core-2.0.11 app/models/spree/property.rb
spree_core-2.0.10 app/models/spree/property.rb
spree_core-2.0.9 app/models/spree/property.rb
spree_core-2.0.8 app/models/spree/property.rb
spree_core-2.0.7 app/models/spree/property.rb
spree_core-2.0.6 app/models/spree/property.rb
spree_core-2.0.5 app/models/spree/property.rb