Sha256: 935cc77821fc4491a7003aa07f05cc3b9b28c9a2ec77c0595f88b5350c80cc95

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 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("#{quoted_table_name}.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 = #{quoted_table_name}.id").
        where(prototype_id: id)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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