Collection_select


#1

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?