Forum: Ruby on Rails Examples of forms using nested resources?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
John S. (Guest)
on 2008-10-29 18:33
Does anyone know of some examples of simple forms using nested

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

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?


John S.
Tim McIntyre (Guest)
on 2008-10-29 19:56
(Received via mailing list)
I think what your looking for is the index attribute on your form

<% form_for :resourece do |form| %>
  <% resourece.sub_resources.each do |sr| %>
    <% fields_for :sr, sr do |sr_fields| %>
      <%= sr_fields.text_field :name, :index =>  %>
    <% end %>
  <% end %>
<% end %>

then the params will be sent to the controller like so:
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!

On Oct 29, 9:33 am, John S. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.