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.

[PATCH] options_for_select do not select boolean values correctly

#5702

options_for_select, given boolean values, do not make false selected

options_for_select([true, false], :selected => false)
=> "<option value=&quot;true&quot;>true</option>\n<option value=&quot;false&quot;>false</option>"

This has some practical value, for example, by giving option for selecting user's sex:

options_for_select({"Male" => true, "Female" => false}, :selected => false)
makes only male selected, which is I'd say, discrimination.

Reported by windock · September 25th, 2010 @ 07:32 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. windock
    windock
    • Tag changed from action_view to action_view, patch

    Patch with test attached.

    September 25th, 2010 @ 07:46 PM

  2. windock
    windock
    • Title changed from options_for_select do not select boolean values correctly to [PATCH] options_for_select do not select boolean values correctly

    September 26th, 2010 @ 12:02 PM

  3. alexrolls
  4. juliavetl
  5. Rovetz
    Rovetz
    [ options.has_key?(:selected) ? options[:selected] : selected, options[:disabled]]
    

    has space missing. Should be

    [ options.has_key?(:selected) ? options[:selected] : selected, options[:disabled] ]
    

    September 30th, 2010 @ 11:53 AM

  6. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:59 PM

  7. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:59 PM

  8. Gudata
    Gudata

    It is fixed from > v3.0.2

    March 9th, 2011 @ 01:37 PM