KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Sep-24 13:41 UTC
Non-database dropdown select - works fine, but why the weird order?
I have built a select_tag dropdown to represent a group of selections that will feed a model-query routine I''ve written. This routine works fine but the order of the items is different than what I programmed. My objection to this order is that I want the ''All => '''''' to be on the top. Here it is; <tr> <td><strong><%= "User Module" %></strong></td> <td> <%= select_tag(:module, options_for_select(''All'' => '''', ''Evidence'' => 1, ''Assets'' => 2, ''Inventory'' => 3, ''Water'' => 4, ''Laboratory'' => 5, ''State EPA'' => 6, ''Administrator'' => 7), :style => "width:206px", :id => :indexselect) %> </td> </tr> and here is the order of items as they ''drop down'' on the form. Laboratory All Administrator Assets Water Evidence Inventory State EPA I am grateful for any suggestions. Kathleen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Maurício Linhares
2008-Sep-24 13:46 UTC
Re: Non-database dropdown select - works fine, but why the weird order?
Hashes in Ruby do not keep the insertion order, you should do it like this: <%= select_tag :module, options_for_select( [ [''All'',''''], [''Evidence'' , 1], [''Assets'', 2], [''Inventory'', 3], [''Water'' , 4], [''Laboratory'' , 5], [''State EPA'', 6], [''Administrator'', 7]]), :style => "width:206px", :id => :indexselect %> On Wed, Sep 24, 2008 at 10:41 AM, KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have built a select_tag dropdown to represent a group of selections > that will feed a model-query routine I''ve written. > This routine works fine but the order of the items is different than > what I programmed. My objection to this order is that I want the ''All > => '''''' to be on the top. > Here it is; > > <tr> > <td><strong><%= "User Module" %></strong></td> > <td> <%= select_tag(:module, options_for_select(''All'' => > '''', ''Evidence'' => 1, ''Assets'' => 2, ''Inventory'' => 3, ''Water'' => 4, > ''Laboratory'' => 5, ''State EPA'' => 6, ''Administrator'' => 7), :style => > "width:206px", :id => :indexselect) %> </td> > </tr> > > and here is the order of items as they ''drop down'' on the form. > > Laboratory > All > Administrator > Assets > Water > Evidence > Inventory > State EPA > > I am grateful for any suggestions. > Kathleen > > >-- Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) João Pessoa, PB, +55 83 8867-7208 --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---