hi, is there any command for sorting the list box items in ROR. if its please tell me -- 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 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 -~----------~----~----~----~------~----~------~--~---
Hi, are the list box items being retrieved from the DB? If so, you can simply use the '':order'' within the find method of your model. For example, orders = Order.find(:all, :order => ["pay_type, shipped_at DESC"], :conditions => "id = ?", 25 ) If not, please provide more information as to how you''re populating the list box. Good luck, -Conrad On 2/21/07, Guest <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > hi, > > is there any command for sorting the list box items in ROR. if its > please tell me > > -- > 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 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 -~----------~----~----~----~------~----~------~--~---
Conrad Taylor wrote:> Hi, are the list box items being retrieved from the DB? If so, you > can simply use the '':order'' within the find method of your model. For > example, > > orders = Order.find(:all, :order => ["pay_type, shipped_at DESC"], > :conditions => "id = ?", 25 ) > > If not, please provide more information as to how you''re populating > the list box. > > Good luck, > > -ConradYou can also sort any array of object by some method or attribute. orders.sort {|a, b| a.total <=> b.total} -- 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 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 -~----------~----~----~----~------~----~------~--~---