title: How create record in HABTM Rails Association How make this?
body: <p>I'm having some trouble creating a new relation in my <code>has_and_belongs_to_many</code> model. I defined the models like this:</p>
  
  <pre><code>journals model
  
    has_and_belongs_to_many :posts
  
  post model
  
    has_and_belongs_to_many :journal
  </code></pre>
  
  <p>I don't know how create the association , I made a button but I don't know how it works. I created the action <code>add_post</code></p>
  
  <pre><code>  def add_post
      @journal_post = JournalsPosts.new
    end
  </code></pre>
  
  <p>I make this link to create the association but I don't know what I have to do now:</p>
  
  <pre><code>&lt;%= link_to "Add to Journal",:controller =&gt; "journals",:action =&gt; "add_post" %&gt;
  </code></pre>
  
  <p>The redirect works correctly but I don't know how to proceed now ? Do you know about some guide to HABTM associations? I have already tried <a href="http://guides.rubyonrails.org/association_basics.html#choosing-between-has_many-through-and-has_and_belongs_to_many" rel="noreferrer">this</a>, but it didn't help.</p>