could anyone please tell me what is wrong this this code?
I get a can’t convert Symbol into Integer
Extracted source (around line #5):
3: <% form_for @song_request do |f| %>
4: <p>Please select the event you are attending:</p>
5: <%= select_tag('song_requests', 'event_id', Event.all.collect {|e| [e.name, e.id ] } ) %>
6: <% end %>
Ok I agree with idlefingers that you have to go with collection_select method here (although it must read
<%= f.collection_select :event_id, Event.all, :name, :id %>) but you also have the alternative to go with the select method asYou have to note that it is a best practice to not use *_tag methods when you wrapping the form fields in a
form_forblock. That is the whole point of usingform_foryou are carrying the object@song_requestin the iterator 🙂