Rails Newb wrote:
> def self.find_active
>     find(:all, :conditions => ['expiration > ?', DateTime.now])

On a side note: Wouldn't this be a good candidate for a named_scope 
rather than a class method?

named_scope :active, lamda { :conditions =>  [ 'expiration > ?', 
DateTime.now ] }

or

named_scope :active, lamda { :conditions =>  [ 'expiration <= ?', 
DateTime.now ] }

or whatever conditions you determine are the right ones for your case.

P.S. This would be more conventional to the Rails framework:

named_scope :active, lamda { :conditions =>  [ 'expires_at > ?', 
DateTime.now ] }

where expires_at is a datetime column in the database.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to