Running into a strange issue and was wondering if others are
experiencing it with the latest rails release.
When using the collection_select helper and passing in a hash for the
options or html_options params I consistently get the following error:
syntax error, unexpected ‘}’, expecting ‘)’
Not using a hash to pass the params works fine (for options at least,
html_options doesn’t seem to).
Let’s assume the following:
Object to update: @product
Methods to update: category_id
Collection to pick from: @categories
Category value field: id
Category text field: name
So this works and will give us the first option “Please select” in the
drop down (due to prompt):
collection_select( :product, :category_id,
@categories, :id, :name, :prompt => true )
However, changing the options param to a hash like this:
collection_select( :product, :category_id, @categories, :id, :name,
{:prompt => true} )
Breaks the form producing this error.
syntax error, unexpected ‘}’, expecting ‘)’
The following attempts break it too:
collection_select( :product, :category_id, @categories, :id, :name,
{} )
collection_select( :product, :category_id, @categories, :id, :name,
{}, {} )
collection_select( :product, :category_id, @categories, :id, :name,
{}, {:onchange => “alert(‘hi’)”} )
Out of ideas.