Rails Many to Many Associations

  1. has_many through

    • requires a join model
    • name your join table anything
      • ex: memberships

    Pros:

    • more flexible, can add additional attributes(solumns) to join table
      Cons:
    • additional join model required
  2. has_and_belongs_to_many

    • no join model necesary
    • assumes join table based on convention
      • ex: groups_users

    Pors:

    • easier, no join model

    Cons:

    • not as flexible, can’t add additional attributes(solumns) to join table