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

34 lines
587 B
Ruby

# -*- encoding : utf-8 -*-
class BlockContent < ActiveRecord::Base
has_many :portlets, :as => :content, :dependent => :destroy
has_many :blocks, :as => :blockable, :dependent => :destroy
validates :nbr_columns, :presence => true
STYLES = [["normal",1],["cadre gris",2]]
def dup
@new = BlockContent.new(self.attributes)
@new.id = nil
@new.save
self.blocks.each do |block|
new_b = block.dup
new_b.blockable = @new
new_b.save
ContentType.all.each do |content_type|
new_b.content_types << content_type
end
end
@new
end
end