jfn_app/app/models/block.rb
Nicolas Bally 0d62fbe429 initial
2011-12-29 11:06:37 +01:00

29 lines
525 B
Ruby

# -*- encoding : utf-8 -*-
class Block < ActiveRecord::Base
belongs_to :blockable, :polymorphic => true
has_many :portlets, :order => :position, :dependent => :destroy
accepts_nested_attributes_for :portlets
has_many :allowed_block_contents
has_many :content_types, :through => :allowed_block_contents
def dup
@block = Block.new(self.attributes)
@block.id = nil
@block.save
self.portlets.each do |portlet|
new_p = portlet.dup
new_p.save
@block.portlets << new_p
end
@block
end
end