is using has_and_belongs_to_many for models is a bad idea?
Can some one please explain the the pros and cons between has_many :through开发者_Go百科 and has_and_belongs_to_many?
There is nothing bad about using habtm per se. The reason why many people don't use this kind of association is that they use has_many :through instead. Why? Because it's more versatile. While HABTM "hides" the intermediary table, when using has_many :through the middle man is a resource by itself - which is usually a good thing (if for nothing, you can timestamp the relationship). You'll come across many situations when you'll need to add some behavior or attributes to such a relationship (when designing a system in a resource-oriented fashion).
精彩评论