19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/cms/behaviors/publishing.rb', line 19
def is_publishable(options={})
@is_publishable = true
extend ClassMethods
include InstanceMethods
attr_accessor :publish_on_save
attr_accessible :publish_on_save
after_save :publish_for_non_versioned
scope :published, :conditions => {:published => true}
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
|