I'm wondering if this is a bug, and if anyone else has noticed this. I have a couple apps on Rails 3.0.0, 3.0.1, and 3.0.2 now. Each one of these apps has some kind of model that has a boolean field. I'm using a select box to toggle "Yes" and "No" answers like this:
<%= f.select(:featured, [["Yes", true], ["No", false]]) %>
This will update my model with the selected option just fine. Here's where it gets weird. If I have my featured column set to false by default, then I create a new instance of this object, and set featured to "No" then save. I will see on my index action that it was properly saved. Then I click edit on this object, and the selected value for featured is set as "Yes". If I hit update without changing this, then it will update the field to true, and display "Yes".
Now, if I change this to
<%= f.select(:featured, [["No", false], ["Yes", true]]) %>
(switch the true and false), then this will work exactly as expected. If the field is saved as true, and I edit, then the selected value will be "Yes", but if the field is saved as false, and I edit, then the selected field will be "No".
Does this make sense?
I would like to submit a patch to Rails, but if this is intended to work
this way, then it's just annoying and I won't bother, but if others have
this same issue, and it's not meant to work that way, then maybe I will
submit a patch
Thanks,
~Jeremy