This project is archived and is in readonly mode.
Form helpers don't handle "question?" methods
Reported by Andrew Vit | May 3rd, 2008 @ 06:49 PM
I'm carrying this forward from my Trac ticket (I rebased the changes to the current revision.)
The form helpers currently don't account for boolean question methods correctly (e.g. :secret?), so it outputs the question mark in the tag's name parameter. This patch fixes the name attribute so the returned parameter corresponds with the the right name for the model's setter method.
Currently, this code:
<%= f.check_box :secret? %>
Produces the following input tag:
<input name="post[secret?]" ... />
In fact, it should produce the following, so that the returned parameter can be directly assigned as :secret=, not :secret?=
<input name="post[secret]" ... />
This would be the expected behaviour for direct assignment back into the model using AR::Base.new, update_attributes, etc...
def create
Post.new( params )
# Currently have to work around the above mass assignment using:
# secret = params.delete(:secret?)
# Post.new( params )
# Post.secret = secret
end
Comments and changes to this ticket
-
Rick May 5th, 2008 @ 08:31 PM
- Assigned user set to Rick
-
Andrew Vit May 5th, 2008 @ 08:50 PM
Updated patch to cache sanitized method name instead of doing the regex each time.
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>