chaix_app/app/models/d_product.rb
Nicolas Bally 6a8e471b82 intial
2019-02-01 13:53:57 +01: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