I''m using the following tag in a partial: <%= select_tag options_from_collection_for_select(@cuisines, "name", "id") %> to create a drop down menu of cuisines. However, the output I''m getting it an empty menu. When I view the source I see the following: <select id="<option value="Lunch Menu">1</option> <option value="Group Bookings">2</option> <option value="BYOB">3</option>" name="<option value="Lunch Menu">1</option> <option value="Group Bookings">2</option> <option value="BYOB">3</option>"></select> Any ideas as to what is going wrong? -- 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 12/8/06, Richard <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I''m using the following tag in a partial: > > <%= select_tag options_from_collection_for_select(@cuisines, "name", > "id") %> > > to create a drop down menu of cuisines. However, the output I''m getting > it an empty menu.First parameter should be the name of the dropdown with options HTML being second: <%= select_tag "cuisine_id", options_from_collection_for_select(@cuisines, "name", "id") %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Maxim Kulkin wrote:> On 12/8/06, Richard <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> >> I''m using the following tag in a partial: >> >> <%= select_tag options_from_collection_for_select(@cuisines, "name", >> "id") %> >> >> to create a drop down menu of cuisines. However, the output I''m getting >> it an empty menu. > > > First parameter should be the name of the dropdown with options HTML > being > second: > > > <%= select_tag "cuisine_id", > options_from_collection_for_select(@cuisines, > "name", "id") %>gah, can''t believe I missed that. Thanks! By the way, is there any way of having one of the menu options select all cuisines? Or could one of the options perhaps send a null value to my action, then I could just say if it''s null show all cuisines. -- 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 -~----------~----~----~----~------~----~------~--~---
You can do something like this: select_tag(''new_member'', options_for_select(['''']+@group.logins_not_in_group)) As you see you can add blank ('''') as a new option. Richard wrote:> Maxim Kulkin wrote: > > On 12/8/06, Richard <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> > >> > >> I''m using the following tag in a partial: > >> > >> <%= select_tag options_from_collection_for_select(@cuisines, "name", > >> "id") %> > >> > >> to create a drop down menu of cuisines. However, the output I''m getting > >> it an empty menu. > > > > > > First parameter should be the name of the dropdown with options HTML > > being > > second: > > > > > > <%= select_tag "cuisine_id", > > options_from_collection_for_select(@cuisines, > > "name", "id") %> > > gah, can''t believe I missed that. Thanks! By the way, is there any way > of having one of the menu options select all cuisines? Or could one of > the options perhaps send a null value to my action, then I could just > say if it''s null show all cuisines. > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Jinal Jhaveri wrote:> You can do something like this: > > select_tag(''new_member'', > options_for_select(['''']+@group.logins_not_in_group)) > > > As you see you can add blank ('''') as a new option.perfect dude! I was looking exactly for this -- 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 -~----------~----~----~----~------~----~------~--~---