This is my select_tag code: <%=select_tag ''project_version_select'', options_for_select(@project_versions)%> How can I set the selected value for this select box? -- 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 -~----------~----~----~----~------~----~------~--~---
On Fri, Jan 9, 2009 at 4:04 AM, Zhao Yi <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > This is my select_tag code: > > <%=select_tag ''project_version_select'', > options_for_select(@project_versions)%> > > How can I set the selected value for this select box? >Look at the documentation for #options_for_select (see http://www.railsbrain.com/api/rails-2.2.2/doc/index.html?a=M002023&name=options_for_select). It takes a second argument which specifies which option should be selected. --wpd --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Patrick Doyle wrote:> <%=select_tag ''project_version_select'', > options_for_select(@project_versions)%> > > How can I set the selected value for this select box? > > Look at the documentation for #options_for_select (see > http://www.railsbrain.com/api/rails-2.2.2/doc/index.html?a=M002023&name=options_for_select > <http://www.railsbrain.com/api/rails-2.2.2/doc/index.html?a=M002023&name=options_for_select>). > It takes a second argument which specifies which option should be selected.Or instead use @my_model_object = look_it_up() select ''my_model_object'', ''my_attribute'', my_map_of_strings_and_values the non-_tag versions of all the helpers are much better because they enforce cleaner controller actions, and they are aware of your objects and members so they can make them sticky. -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---