I have several select options on a form and was planning on using options_for_select. If I use the code below the options do not appear in order on the form, I am not really sure of the order they are appearing since it is not alphabetical either. <%= options_for_select({"Co-ed" => "Co-ed", "Men" => "Men", "Women" => "Women", "Please select student body" => "None"}, "None") %> Would I be better off to use a traditional HTML <option> tag and put my options in the order I want them to display? For the record this is the order they display now on the form with the code above: Men Please select student body Co-ed Women Thanks! -Scott --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Instead of a hash, try passing in an ActiveSupport::OrderedHash options = ActiveSupport::OrderedHash.new options["Co-ed"] = "Co-ed" options[""Men"] = "Men" etc. It is ugly tho :-( Vish On 8/14/07, Scott Parks <scottaparks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have several select options on a form and was planning on using > options_for_select. > > If I use the code below the options do not appear in order on the > form, I am not really > sure of the order they are appearing since it is not alphabetical > either. > > <%= options_for_select({"Co-ed" => "Co-ed", "Men" => "Men", "Women" > => "Women", "Please select student body" => "None"}, "None") %> > > Would I be better off to use a traditional HTML <option> tag and put > my options in the > order I want them to display? > > For the record this is the order they display now on the form with > the code above: > > Men > Please select student body > Co-ed > Women > > Thanks! > > -Scott > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That works, but as you said it is kind of ugly, this is a new user form so I am not worried about making the select''s sticky. Do you see a need to do it this way if the values are static? Or is a regular <option> tag ok? On Aug 13, 2007, at 4:01 PM, Vishnu Gopal wrote:> > Instead of a hash, try passing in an ActiveSupport::OrderedHash > > options = ActiveSupport::OrderedHash.new > options["Co-ed"] = "Co-ed" > options[""Men"] = "Men" > etc. > > It is ugly tho :-( > > Vish > > On 8/14/07, Scott Parks <scottaparks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> I have several select options on a form and was planning on using >> options_for_select. >> >> If I use the code below the options do not appear in order on the >> form, I am not really >> sure of the order they are appearing since it is not alphabetical >> either. >> >> <%= options_for_select({"Co-ed" => "Co-ed", "Men" => "Men", "Women" >> => "Women", "Please select student body" => "None"}, "None") %> >> >> Would I be better off to use a traditional HTML <option> tag and put >> my options in the >> order I want them to display? >> >> For the record this is the order they display now on the form with >> the code above: >> >> Men >> Please select student body >> Co-ed >> Women >> >> Thanks! >> >> -Scott >> >> >>> >> > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---