Form involving several models related to each other I have a form that I feel I am overcomplicating because of the relationship between models that are involved.  Can you let me know if there's a more elegant solution to what I have?

(for reference) The form ultimately looks like this:



The relationship between the involved models:

user_relation has_many :user_relation_skills
user_relation_skills has_many :progresses
progress has_many :ratings, :as =&gt; :ratable


The form looks like this (I removed most of the classes/extraneous information but left the divs in to give a better idea of whats going on):

&lt;%= simple_form_for(@user_relation) do |f| %&gt;
    &lt;%= f.fields_for :user_relation_skills do |ff| %&gt;
        &lt;%= ff.fields_for :progresses do |fff| %&gt;
            &lt;%= fff.fields_for :ratings do |ffff| %&gt;
                &lt;div&gt;   
                    &lt;div&gt; 
                        &lt;%= link_to(user_relation_skill_path(ffff.object.scope)) do %&gt;
                          &lt;%= ffff.object.scope.skill.category.name %&gt;&amp;nbsp&lt;i class='icon-arrow-right'&gt;&lt;/i&gt;&amp;nbsp&lt;%= ffff.object.scope.skill.name %&gt;
                        &lt;% end %&gt;
                    &lt;/div&gt;
                &lt;/div&gt;

                &lt;% if @current_type_for_views == 'coach' %&gt;
                    &lt;div&gt;   
                        &lt;div&gt;
                            &lt;%= ffff.select("value", 1..8, {}, {class: "ratings-skill"}) %&gt;
                        &lt;/div&gt;
                        &lt;div&gt;   
                            &lt;div class='small-offset-8 small-4 columns'&gt;
                                &lt;%= button_tag(type: 'submit', class: "small button") do %&gt;
                                    &lt;i class="icon-check"&gt;&lt;/i&gt;Update 
                                &lt;% end %&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;

                &lt;% else %&gt;

                    &lt;div&gt;   
                        &lt;div&gt;
                            &lt;%= ffff.select("value", 1..8, {}, {class: "static-rating"}) %&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;% end %&gt;

            &lt;% end %&gt;
        &lt;% end %&gt;
    &lt;% end %&gt;
&lt;% end %&gt;


Are this many 'nests' in a form typical or should I be doing something else?

I'm including part of a simple UML diagram with a focus on the "Rating" model that is attached to many things (there are lots of things in the app that can be rated):

Most of the lines going up out of the screen connect either to unimportant models or Active Record directly.  The only pertinent thing that is not pictured is the fact that Rating rates Users (a user model that someone would typically expect).
This view knows far too much about your data model structure.

One level of nesting is reasonably acceptable, but this many is dangerous : in fact, this view needs knowledge about no less than 4 different business objects, not to mention it has to know the relations between them.

Solution 1 : the facade pattern

Abstract away all those details in another object, which would be the sole source of truth for your view : call it a form object, or a presenter, or a context in DCI idiom, whatever.

The idea is that this object has a simple interface that maps to the complex underlying system. We'd need more details on your business logic to be able to help you on this one.

Solution 2 : cook your own "accepts_nested_attributes" method

on your UserRelation model, create a ratings method that provides direct access to your ratings. Then create another method that allows assignment, like ratings_attributes=. In this method, process the passed parameters to create / update associated ratings ; you can find inspiration for this in the source for the accept_nested_attributes method.