# -*- encoding : utf-8 -*- class Folder < ActiveRecord::Base belongs_to :image_file after_create :after_creation has_one :block, :as => :blockable has_many :articles validates :title, :presence => true validates :slug, :presence => true, :uniqueness => true def after_creation @block = Block.new(:block_name => "en tĂȘte") @block.blockable = self @block.save ContentType.all.each do |content_type| @block.content_types << content_type end end before_validation do self.slug = self.slug.to_slug end end