payre3p_app/app/models/d_product.rb
2018-08-02 23:49:05 +02:00

32 lines
568 B
Ruby

class DProduct < ActiveRecord::Base
has_many :blocks, :as => :blockable
after_create :after_creation
attr_accessor :skip_block
belongs_to :image_file
belongs_to :icon, :class_name => "ImageFile"
before_validation do
self.slug = self.name.to_slug if !self.slug?
end
def after_creation
if !skip_block
LangSite.all.each do |lang|
@block = Block.new(:block_name => "Contenu", :lang_site => lang)
@block.blockable = self
@block.save
end
end
end
end