Collections and Nested Attribute Forms
Assume I have the models Foo and Bar, where Bar is a nested attribute of Foo.
<%= form_for @foo do |f| %>
<%= f.fields_for :bars do |builder| %>
<%= render 'bar_fields', :f => builder %>
<% end %>
<%= f.submit %>
<% end %>
The partial bar_fields has the fields that correspond to the attributes in Bar. I only want to edit certain 开发者_运维知识库fields in this model, so I've left out these out. Instead I want to output the values of these fields as text and to be able to access their ActiveRecord relations.
How would I go about doing this?
To access object variables from a form helper do:
f.object.your_variable
精彩评论