title: How to have many-to-many relationship in rails
body: <p>I am new to rails, and am trying to set up a many-to-many relationship in my rails project. I have a small strategy, but I am not sure if its the correct way.</p>
  
  <p><strong>Aim:</strong>
  I have a table of users, and a table of groups. Users can be part of many groups, and each group may have many users. </p>
  
  <p><strong>Strategy:</strong></p>
  
  <ol>
  <li>Set up User migration to have name:string</li>
  <li>Set up Group migration to have name:string</li>
  <li>Set up a Join table migration</li>
  <li>Set up User model such that it would have has_and_belongs_to_many :groups</li>
  <li>Set up Group model such that it would have has_and_belongs_to_many :users</li>
  </ol>
  
  <p>Would this be the correct strategy? Thanks!</p>
  
  <p><strong>Railcast Summary from answer:</strong>
  For those that are interested - Railcast suggests you to use a has_many :through association since the strategy above has the limitation that you cannot add extra relation-specific information. </p>
  
  <p>check out: <a href="http://kconrails.com/tag/has_many/" rel="noreferrer">http://kconrails.com/tag/has_many/</a></p>