16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/cms/behaviors/publishing.rb', line 16
def is_publishable(options={})
@is_publishable = true
extend ClassMethods
include InstanceMethods
attr_accessor :publish_on_save
after_save :publish_for_non_versioned
named_scope :published, :conditions => {:published => true}
named_scope :unpublished, lambda {
if versioned?
{ :joins => :versions,
:conditions =>
"#{connection.quote_table_name(version_table_name)}.#{connection.quote_column_name('version')} > " +
"#{connection.quote_table_name(table_name)}.#{connection.quote_column_name('version')}",
:select => "distinct #{connection.quote_table_name(table_name)}.*" }
else
{ :conditions => { :published => false } }
end
}
end
|