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 my experience it's always better to use `has_many: through` because you can add timestamps to the table. Many times while debugging some `ActiveRecord` objects that are connected through HABTM, I was missing `created_at`, `updated_at` timestamps to get the clue what actually happened.

So keep in mind that it can help you to debug, investigate an issues with the data relations in the context of the time, because without it you are "blind" when relations were created or updated.
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**.