1 class Topic
< ActiveRecord
::Base
3 named_scope
:written_before, lambda
{ |time
|
5 { :conditions => ['written_on < ?', time
] }
8 named_scope
:approved, :conditions => {:approved => true}
9 named_scope
:rejected, :conditions => {:approved => false}
11 named_scope
:by_lifo, :conditions => {:author_name => 'lifo'}
13 named_scope
:approved_as_hash_condition, :conditions => {:topics => {:approved => true}}
14 named_scope
'approved_as_string', :conditions => {:approved => true}
15 named_scope
:replied, :conditions => ['replies_count > 0']
16 named_scope
:anonymous_extension do
26 module MultipleExtensionOne
31 module MultipleExtensionTwo
36 named_scope
:named_extension, :extend => NamedExtension
37 named_scope
:multiple_extensions, :extend => [MultipleExtensionTwo
, MultipleExtensionOne
]
39 named_scope
:by_rejected_ids, lambda
{{ :conditions => { :id => all(:conditions => {:approved => false}).map(&:id) } }}
41 has_many
:replies, :dependent => :destroy, :foreign_key => "parent_id"
44 before_create
:default_written_on
45 before_destroy
:destroy_children
51 # trivial method for testing Array#to_xml with :methods
58 @custom_approved = val
59 write_attribute(:approved, val
)
62 def default_written_on
63 self.written_on
= Time
.now
unless attribute_present
?("written_on")
67 self.class.delete_all
"parent_id = #{id}"
72 self.author_email_address
= 'test@test.com'
78 class Topic
< ActiveRecord
::Base
79 has_many
:replies, :dependent => :destroy, :foreign_key => "parent_id", :class_name => 'Web::Reply'