This project is archived and is in readonly mode.

#6256 ✓committed
John Allison

[PATCH] select helpers with boolean attributes

Reported by John Allison | January 5th, 2011 @ 07:39 PM | in 3.1

While upgrading to rails 3.0.3, I ran into the following problem:

    # blog.rb
    class Blog < ActiveRecord::Base
      # allow_comments :boolean(1) default(FALSE)
      # ...
    end
    
    # view inside a form_for(@blog)
    <%= f.select :allow_comments, [["On", true], ["Off", false]] %>

If allow_comments was true, "On" would be selected. If allow_comments was false, "Off" would NOT be selected. I've fixed this in the attached patch.

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>

Pages