If you are using Rails 2.1 or greater, then named_scope would be very useful.

In your Blog model for example, you can specify a recent named_scope
to return all entries less than 24 hours old.

named_scope :recent, :conditions => [ "created_at > ?", Time.now - 24.hours ]

and maybe another one for unpublished entries

# modify the conditions and include accordingly as I don't know enough about
# your models
named_scope :unpublished, :include => :status, :conditions =>
"statuses.status != 'published'"

In your controllers then, you can do something like

@new_unpublished_entries = Blog.unpublished.recent

-- 
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