# Rails 2.02 collection\_select problem passing option and html\_option hashes

**URL:** <https://www.ruby-forum.com/t/rails-2-02-collection-select-problem-passing-option-and-html-option-hashes/130368>\
**Category:** Rails\
**Created:** [February 27, 2008, 6:36pm UTC](https://www.ruby-forum.com/t/rails-2-02-collection-select-problem-passing-option-and-html-option-hashes/130368 "2008-02-27T18:36:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Rapin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3d9bf3/32.png) [@Dave\_Rapin](https://www.ruby-forum.com/u/Dave_Rapin)\
**Post date:** [February 27, 2008, 6:36pm UTC](https://www.ruby-forum.com/t/rails-2-02-collection-select-problem-passing-option-and-html-option-hashes/130368/1 "2008-02-27T18:36:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dave\_Rapin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3d9bf3/32.png) [@Dave\_Rapin](https://www.ruby-forum.com/u/Dave_Rapin)\
**Post date:** [February 27, 2008, 8:34pm UTC](https://www.ruby-forum.com/t/rails-2-02-collection-select-problem-passing-option-and-html-option-hashes/130368/2 "2008-02-27T20:34:25Z")

</div>

Dave Rapin wrote:

> 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 ‘)’

I’m sure this will be of no use to you, but I just stuck:

```
<%= collection_select :user, :articles, @articles, :id,
                      :title, {:prompt => true},
                      {:onchange => "alert('hi')"} %>

```

into one of my views and it worked just fine, popup alert and all.

Rails 2.0.2 on MacOS 10.5.1, ruby 1.8.6

---

<div class="post-metadata">

**Author:** ![Dave\_Rapin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3d9bf3/32.png) [@Dave\_Rapin](https://www.ruby-forum.com/u/Dave_Rapin)\
**Post date:** [February 27, 2008, 9:13pm UTC](https://www.ruby-forum.com/t/rails-2-02-collection-select-problem-passing-option-and-html-option-hashes/130368/3 "2008-02-27T21:13:08Z")

</div>

Very strange. Ok thanks. You’re on the latest rails release or on  
edge? Maybe it’s a haml problem for me then.

On Feb 27, 2:34 pm, Mark B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Dave\_Rapin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3d9bf3/32.png) [@Dave\_Rapin](https://www.ruby-forum.com/u/Dave_Rapin)\
**Post date:** [February 27, 2008, 9:14pm UTC](https://www.ruby-forum.com/t/rails-2-02-collection-select-problem-passing-option-and-html-option-hashes/130368/4 "2008-02-27T21:14:21Z")

</div>

Nevermind. I see you’re on 2.02 same as me. Ok thanks for the update.  
Gotta be something else.
