This project is archived and is in readonly mode.

#96 ✓resolved
Andrew Vit

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, update_attributes, etc...

def create params )

  # Currently have to work around the above mass assignment using:
  # secret = params.delete(:secret?)
  # params )
  # Post.secret = secret

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=""></a>

People watching this ticket