I''m trying to populate a select box with a collection. I have the
following code in my view:
<%= collection_select(:heading, @headings, :id, :name, nil, {:onChange
=> ''submit();''}) %>
But when I run it, I get an exception and the following error:
undefined method `inject'' for :id:Symbol
What''s going on here? Does collection_select have to be used inside a
form_for rather than a form_tag?
Alternatively, is there anyway to use select_tag and have it use an
onchange javascript event?
--
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
-~----------~----~----~----~------~----~------~--~---
hey, i have a model called continents, that has a name and an id, anyone know why this doesnt work <%= collection_select(:continent, :name, @continents, :id, :name), but this does <%= collection_select(:continent, :id, @continents, :id, :name), many thanks The first results in a: undefined method `name'' for #<Array:0x22cff08> Thankyou. -- 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 -~----------~----~----~----~------~----~------~--~---
Fixed it myself, i actually put the correct code in this post, in my app, i had @continent, instead of @continents, didnt realise it was plural sensitive. -- 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 -~----------~----~----~----~------~----~------~--~---