Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

collection_select doesn't select current choice

#1138

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

Reported by Florian Zschetzsche · September 29th, 2008 @ 09:30 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Florian Zschetzsche
  2. Pratik
    Pratik
    • Tag changed from 2.0-stable, 2.1, actionpack, helper to 2.0-stable, 2.1, actionpack, helper
    • State changed from new to invalid

    I think you should try asking this on the mailing list - http://groups.google.com/group/r...

    Thanks!

    January 5th, 2009 @ 05:53 PM