# Nested forms without looping through fields\_for collection

**URL:** <https://www.ruby-forum.com/t/nested-forms-without-looping-through-fields-for-collection/166075>\
**Category:** Rails\
**Created:** [April 21, 2009, 6:22pm UTC](https://www.ruby-forum.com/t/nested-forms-without-looping-through-fields-for-collection/166075 "2009-04-21T18:22:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 21, 2009, 6:22pm UTC](https://www.ruby-forum.com/t/nested-forms-without-looping-through-fields-for-collection/166075/1 "2009-04-21T18:22:00Z")

</div>

Hi,

I have a fairly complex form and I am wondering if it is even possible  
to do what I am attempting.

I have multiple models included in the form. A small example would be  
the following:

Company has many Locations  
Company has many PhoneNumbers… and so on

I have this working without issue using Rails 2.3 and nested forms.

Where this becomes complex is that I also have another model named  
Rankings. I allow my users to assign a raking to each of the fields  
that are entered. Each model has a has many :through relationship with  
Rankings. I wish to send these fields back to the server in a nested  
format with the attribute that they belong to, as well as with the  
field name that they are being assigned to. I have attempted to use a  
fields\_for, but it simply loops through the entire set of Rankings  
duplicating each of the attributes multiple times.

Does anyone have a suggestion to implement this?

Thanks!
