Rails 3: difference between has_many :through and has_and_belongs_to_many

Posted by Arkham on May 24th, 2011

From Rails guides:

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).

This entry was posted on Tuesday, May 24th, 2011 at 10:52 and is filed under thoughts. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Tags: , , ,

Comments are closed.