Blah Blah Woof Woof

Archived content 2005-2007

Rails form helpers should not require an instance variable

Posted by Tim Riley Fri, 04 May 2007 07:24:00 GMT

From ticket #2726 in the Rails Trac:

The form helpers assume the object you want them to reference is an instance variable, ie: they require an ’@’. This makes them completely useless in a partial unless I explicitly include something like ”@user = user” at the top of each partial.

I came across this limitation today when I was using partials to contain forms to edit a collection of objects.

Right now the only way I can see to work around this is to add that additional line at the top of the partials in question. Seems that the form helpers were really only designed to work best in the view that receives instance variables directly from the controller.

Comments

(leave url/email »)