Formhelper methods don't work with render collection partial


#1

I’m rendering a partial using a collection:

<%=render(:partial=> ‘record’, :collection => @records)%>

Inside the partial, I’m attempting to create a new form for each row,
generating elements like the following example:

<%= text_field “record”, “name” %>

However, though my objects are fully populated, these form tags ignore
the values completely. Is this due to a scope issue? Can this be
resolved?


#2

You can assign the local variable ‘record’ to the instance variable
@record’ in your partial template. Or, if you are using edge rails,
you can use form_for helper like:

<%= form_for :record, record, :url => {} %>
<%= text_field “record”, “name” %>
<%= end %>


Kent

http://www.datanoise.com