title: Examples of new, create actions for has_many :through associations (nested)
body: <p>I found this code on <a href="http://guides.rubyonrails.org/association_basics.html#the-has_one-through-association" rel="nofollow">http://guides.rubyonrails.org/association_basics.html#the-has_one-through-association</a>:</p>
  
  <pre><code>class Document &lt; ActiveRecord::Base
    has_many :sections
    has_many :paragraphs, :through =&gt; :sections
  end
  
  class Section &lt; ActiveRecord::Base
    belongs_to :document
    has_many :paragraphs
  end
  
  class Paragraph &lt; ActiveRecord::Base
    belongs_to :section
  end
  </code></pre>
  
  <p>This is exactly what I'm trying to accomplish, but I'm still very new to Rails and was wondering if someone could show me a sample of the forms and the controllers needed in order to be able to create records for this setup?</p>
  
  <p>I was able to create the first part (document has many sections) but I'm stuck on figuring out how to implement sections have many paragraphs and how to be able to reference between the three. I've searched high and low for the above example and would REALLY appreciate a sample code of the new, create, update actions and corresponding forms.</p>
  
  <p>Thanks so much in advance!</p>
  
  <p>UPDATED: 
  I really appreciate your help with this and thanks for the quick reply. Perhaps I need to clarify a little. </p>
  
  <p>I have my 3 models (user, publication, issue) and they are separated in each of their own views and controllers. The goal is to have a control panel where logged in users can click links to:</p>
  
  <p>a) add/edit/delete publications related to individual users</p>
  
  <p>b) add/edit/delete issues related to individual publications</p>
  
  <p>Hence I have 3 separate forms as well (user, publication &amp; issue).</p>
  
  <p>In my publications_controller I managed to:</p>
  
  <pre><code>@publication = current_user.publications.build(params[:publication])
  </code></pre>
  
  <p>Which links users and publications together and populates with the correct user_id field in the publications model (which is not listed in attr_accessible) so that works great.</p>
  
  <p>Now my challenge is to add issues to publications and this is where I fall a little short. I have a menu where I can add issues, but I don't want the publication_id field in the form and neither have it in attr_accessible in the model. I want to create an issue through the user with the selected publication.</p>
  
  <p>I'm sorry if I can't explain it well this is all still very new to me, and possibly also why I'm having trouble searching for the correct terminology.</p>