8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/publinator.rb', line 8
def acts_as_publishable(options = {})
has_one :publication,
:as => :publishable,
:class_name => "Publinator::Publication",
:foreign_key => :publishable_id,
:dependent => :destroy
accepts_nested_attributes_for :publication
validates_presence_of :publication
validates_associated :publication
has_many :asset_items,
:as => :assetable,
:class_name => "Publinator::AssetItem",
:foreign_key => :assetable_id,
:order => 'position'
accepts_nested_attributes_for :asset_items, :reject_if => :all_blank
before_validation :verify_publication
attr_accessible :site, :publication, :section, :default,
:position, :asset_items_attributes,
:custom_slug, :site_id, :section_id,
:publication_attributes
attr_accessor :default
scope :non_index, joins(:publication).where("publication.slug != 'index'")
delegate :site, :position, :section, :slug, :to => :publication
end
|