title: Rails autosave association in controller action
body: <p>I have the following one to many associations. Document has many Sections and Section has many Items.</p>
  
  <pre><code>class Document &lt; ActiveRecord::Base
    has_many :document_sections, :dependent =&gt; :destroy, :autosave =&gt; true
    has_many :document_items, :through =&gt; :document_sections
  end
  
  class DocumentSection &lt; ActiveRecord::Base
    belongs_to :document
    has_many :document_items, :dependent =&gt; :destroy, :autosave =&gt; true
  end
  
  class DocumentItem &lt; ActiveRecord::Base
    belongs_to :document_section
  end
  </code></pre>
  
  <p>Here is the params hash:</p>
  
  <pre><code>-
  Parameters: {"commit"=&gt;"Submit Document", "authenticity_token"=&gt;"4nx2B0pJkvavDmkEQ305ABHy+h5R4bZTrmHUv1setnc=", "id"=&gt;"10184", "document"=&gt;{"section"=&gt;{"10254"=&gt;{"seqnum"=&gt;"3", "item"=&gt;{"10259"=&gt;{"comments"=&gt;"tada"}}}}, "comment"=&gt;"blah"}}
  </code></pre>
  
  <p>I have the following update method...</p>
  
  <pre><code># PUT /documents/1                                                                                                                                                 
  # PUT /documents/1.xml
  
  
  
  
  def update
      @document = Document.find(params[:id])
  
      # This is header comment
      @document.comment = params[:document][:comment]
  
      params[:document][:section].each do |k,v|
         document_section =  @document.document_sections.find_by_id(k)
         if document_section
  
            v[:item].each do |key, value|
               document_item = document_section.feedback_items.find_by_id(key)
               if document_item
  
                  # This is item comments
                  document_item.comments = value[:comments]
               end
            end
  
         end
       end
  
      @document.save
  
    end
  </code></pre>
  
  <p>When I save the document it only updates the document header comments. It does not save the document_item comments. Shouldn't the autosave option also update the associations.</p>
  
  <p>In the log only the following DML is registered:</p>
  
  <pre><code>UPDATE documents SET updated_at = TO_DATE('2010-03-09 08:35:59','YYYY-MM-DD HH24:MI:SS'), comment = 'blah' WHERE id = 10184
  </code></pre>
  
  <p>How do I save the associations by saving the document.</p>