Possible bug in form_for


#1

I’m not sure if I found a bug, or just an undocumented corner of
form_for and wanted to see if anyone here can provide any insight
before I open a Trac ticket.

When using form_form and passing multiple parameters to the :url hash
the block parameter wasn’t getting initialized (“f” in the example
below)

<%
form_for :person, :url=>{:short_name=>@competition, :action=>:start}
do |f| -%>
<%= f.text_field :foo -%>
<% end -%>

Will result in an error message like "undefined local variable or
method “f” on the f.text_field line. This error only occured in test
environments, never in production.

The above error happened under autotest and rake:test. Running an
individual test case however would normally yield a “You have a nil
object … nil.text_field” style error message insteaad.

If I change it to
<% form_for :person,
@person, :url=>{:short_name=>@competition, :action=>:start} do |f| -%>
<%= f.text_field :foo -%>
<% end -%>

it now works, but I was under the impression that the explicit model
object variable wasn’t required. Is this a bug in form_for? or is
there some undocumented requirement for the explicit model obejct in
certain cases?

Thanks