40 lines
675 B
Ruby
Executable File
40 lines
675 B
Ruby
Executable File
# -*- encoding : utf-8 -*-
|
|
|
|
class Newsletter < ActiveRecord::Base
|
|
validates_presence_of :subject
|
|
|
|
validates :slug, :presence => true, :uniqueness => true
|
|
has_one :block, :as => :blockable
|
|
after_create :after_creation
|
|
|
|
def after_creation
|
|
@block = Block.new(:block_name => "Contenu")
|
|
@block.blockable = self
|
|
@block.save
|
|
|
|
|
|
end
|
|
|
|
before_validation do
|
|
|
|
|
|
|
|
if !self.slug?
|
|
self.slug = self.subject
|
|
|
|
end
|
|
|
|
self.slug = self.slug.to_slug
|
|
|
|
|
|
end
|
|
|
|
def alloweds_types
|
|
self.block.allow_types :TitleContent, :TextContent, :ImageContent, :LinkContent, :GalleryContent, :HtmlContent, :DownloadContent
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|