Does anyone know of some examples of simple forms using nested
resources?
I want to have a parent record, with many child records all on the one
form, and have all the add, edit, delete etc methods available on the
children.
This seems to be an obvious use for the nested routes that are generated
by nested resources so I assume someone has this all worked out
somewhere. Or is it so obvious that no explanation is required?
Thanks
John S.
I think what your looking for is the index attribute on your form
fields:
<% form_for :resourece do |form| %>
<% resourece.sub_resources.each do |sr| %>
<% fields_for :sr, sr do |sr_fields| %>
<%= sr_fields.text_field :name, :index => sr.id %>
<% end %>
<% end %>
<% end %>
then the params will be sent to the controller like so:
sub_resource[i][:name]
where “i” is the index set in the above field
something like that anyway… hope that sets you on the right track…
you may want to search around the group a bit more I know there has
been discussions on this.
good luck!
Tim
On Oct 29, 9:33 am, John S. [email protected]