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!
--
[73, 32, 108, 111, 118, 101, 32, 121, 111, 117, 32, 115, 111, 32, 109, 117,
99, 104, 33].map{|c| c.chr}.join
Only two surfaces of a box:
http://blog.pixnet.net/zusocfc
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you, Philip :) On Tue, Mar 10, 2009 at 11:32 AM, Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org> wrote:> > > 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 > > > >-- [73, 32, 108, 111, 118, 101, 32, 121, 111, 117, 32, 115, 111, 32, 109, 117, 99, 104, 33].map{|c| c.chr}.join Only two surfaces of a box: http://blog.pixnet.net/zusocfc --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---