class Newsletter < ActiveRecord::Base after_create :after_creation has_one :block, :as => :blockable def after_creation @block = Block.new(:block_name => "Contenu") @block.blockable = self @block.save ContentType.all.each do |content_type| @block.content_types << content_type end end end