On Mar 9, 2009, at 8:22 PM, CFC wrote:
> 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.
> [code]
> Bulletin.all #=> Same as: Bulletin.find(:all, {:order => "publish_at
> DESC"})
> [/code]
>
> 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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---