negos_app/app/models/product_collection.rb
2017-09-19 11:33:15 +02:00

23 lines
555 B
Ruby
Executable File

class ProductCollection < ActiveRecord::Base
belongs_to :product_category
has_many :product_collection_langs, :dependent => :destroy
accepts_nested_attributes_for :product_collection_langs
has_many :products, :dependent => :nullify
belongs_to :image_file
before_validation do
self.product_collection_langs.each do |product_collection_lang|
product_collection_lang.product_category_id = self.product_category_id
end
end
def lang(lang)
self.product_collection_langs.find_by_lang(lang)
end
end