# -*- 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
