How can I set default order in Model.rb?

Hi, all
How can I set a default order in a model.rb?

For an instance, I have a model called “Bulletin”
I want all query with ‘find’ method return records by ordered.

Bulletin.all #=> Same as: Bulletin.find(:all, {:order => "publish_at DESC"})

Should I write a method to do that? Or I can set something in the bulletin model?

Thanks!

It depends on what version of Rails you're running. 2.3 has it built in. Prior to that there is a plugin. Go to agilewebdevelopment.com/plugins and search for "default order". Or read the release notes for 2.3.

-philip

Thank you, Philip :slight_smile: