Hello, I have the following code in the little application that I am writing. It is basically taken directly out of the Agile Web Development with Rails book. In the controller: @exercises = Exercise.find(:all).map { |f| [f.name, f.id] } And in the view <% form_tag :action => ''create'' do %> .... <label for="exercises">Exercise: </label><%= select_tag(:id, @exercises) %> <% end %> And this is what it is producing: <label for="exercises">Exercise: </label><select id="id" name="id">Incline Dumbbell Press1Push-up2Squats3Incline Dumbbell Press4Push-up5Squats6asdfasdf7another test8asdfasdfasdfasdfasdf12349asdfasdfasdfasdfasdf123410111test exercise - no description12testing error stuffs13</select> This is obviously not what I was expecting. It makes it really hard to pick something from what I thought would be a nice little drop down select widget. What am I doing wrong? Thanks, Chris -- www.fuzzylizard.com You know you''ve achieved perfection in design, Not when you have nothing more to add, But when you have nothing more to take away. -- Antoine de Saint-Exupery --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M000604 select_tag creates the <select></select> tag, but you need to add in the options you want...do something like this: http://api.rubyonrails.com/classes/ActionView/Helpers/FormOptionsHelper.html#M000511 select_tag("id", options_from_collection_for_select(@excersises, "title", "id")) hth :) -- 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 -~----------~----~----~----~------~----~------~--~---
This worked, thanks. Chris On 7/10/07, Shai Rosenfeld <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > > http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M000604 > > select_tag creates the <select></select> tag, but you need to add in the > options you want...do something like this: > > > http://api.rubyonrails.com/classes/ActionView/Helpers/FormOptionsHelper.html#M000511 > > select_tag("id", options_from_collection_for_select(@excersises, > "title", "id"))-- www.fuzzylizard.com You know you''ve achieved perfection in design, Not when you have nothing more to add, But when you have nothing more to take away. -- Antoine de Saint-Exupery --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---