Question: What is the difference between the  

`has_and_belongs_to_many` and  

`has_many through` relationships? When and where to use which one?

Answer: 
From <http://guides.rubyonrails.org/association_basics.html#choosing-between-has-many-through-and-has-and-belongs-to-many>

> 
> The simplest rule of thumb is that you should set up a has\_many :through relationship if you need to work with the relationship model as an independent entity. If you don’t need to do anything with the relationship model, it may be simpler to set up a has\_and\_belongs\_to\_many relationship (though you’ll need to remember to create the joining table in the database).
>  You should use has\_many :through if you need validations, callbacks, or extra attributes on the join model.
> 
> 
>
Rails offers two different ways to declare a **many-to-many** relationship between models. The first way is to use **has\_and\_belongs\_to\_many**, which allows you to make the association directly:

The second way to declare a many-to-many relationship is to use **has\_many :through.** This makes the association indirectly, through a **join model**:

**You should use has\_many :through if you need validations, callbacks, or extra attributes on the join model**.