Sha256: 92a74864ce43c1d9edd08b4f4faad6fa39cd923e41709b14840b89ed948eae4d
Contents?: true
Size: 729 Bytes
Versions: 13
Compression:
Stored size: 729 Bytes
Contents
module Spree class Property < Spree::Base has_and_belongs_to_many :prototypes, join_table: 'spree_properties_prototypes' has_many :product_properties, dependent: :delete_all, inverse_of: :property has_many :products, through: :product_properties validates :name, :presentation, presence: true scope :sorted, -> { order(:name) } after_touch :touch_all_products 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 private def touch_all_products products.each(&:touch) end end end
Version data entries
13 entries across 13 versions & 1 rubygems