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