29 lines
525 B
Ruby
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
|