I have nested attributes for say comment. The parent class is post.
<% form_for @post do |f| %>
...........
<% f.fields_for :comments do |builder| %>
<%= builder.text_field :name %>
<%= builder.text_field :address %>
<%= builder.hidden_field :label, :value => user_1 %>
<%= builder.text_field :name %>
<%= builder.text_field :address %>
<%= builder.hidden_field :label, :value => user_2 %>
<% end %>
<% end %>
When I save posts I want to save the comments also, And I need the different values for hidden_field, if I use form tag, I don't know how will it save the comments without doing anything in the controller.
I have also used :accepts_nested_attributes_for :comment in the post model. If anybody could give it a second thought, that'll be great.
name, address and label are the fields of comment. When I save post, I need two rows of comments to be saved. One from first text_field, text_field and hidden_field and another row from the second input fields.