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: 
My rule of thumb is, can I get by with a list of checkboxes here? If so, then it's a has-and-belongs-to-many (HABTM) association. If I need the checkbox to capture more about the relationship than simply yes/no it belongs, then use `has_many :through`. HABTM is as simple as using the \_ids method with a simple\_form collection\_check\_boxes. `has_many :through` often involves `accepts_nested_attributes_for`.
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**.