In AWDWR David says (pg 232),
"When a Join Wants to Be a Model:
While a many-to-many relation with attributes can often seem like the
obvious choice, itâ??s often a mirage for a missing domain model. When
it is, it can be advantageous to convert this relationship into a
and decorate it with a richer set of behavior. This lets you
data with methods.
As an example, we could turn the articles_users relationship into a new
model called Reading. This Reading model will belong_to both an article
and a user. And itâ??s now the obvious spot to place methods such as
find_popular_articles( ), which can perform a group by quer y and
articles that have been read the most. This lightens the burden on
cle model and turns the concept of popularity into a separated concern
that naturally sits with the Reading model. "
First, I assume this means that the other model definitions need to
have a “has_many:” declaration for this new model that will belong to
Is anyone aware of where I might look to find more information on
this kind of alternative setup? How often have any of you chosen the
method described here as opposed to just using HABTM? What are some
of the main trade-offs in using either?
Thanks in advance!