This project is archived and is in readonly mode.

#1138 ✓invalid
Florian Zschetzsche

collection_select doesn't select current choice

Reported by Florian Zschetzsche | September 29th, 2008 @ 09:30 PM | in 2.x

Hi everybody,

I've discovered a problem when using collection_select in a user registration form:


f.collection_select(:province_id, Province.find(:all), :id, :name,
                  {:prompt   => "Select a Province"})

The problem is, that later on in options_for_select the selected value is still available, but as a String object and not like the id as FixNum.

For now I'm using a stupid workaround like:


selected_attribute = ' selected="selected"' if option_value_selected?(value.to_s, selected)

Anyway I'd like to hear a statement from the developers - am I using the helper in a wrong way?!

I tried using it with Rails 2.0.2 and 2.1.1

Thank you so much!

Best regards, Florian

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages