Displaying 2 results from an estimated 2 matches for "articles_us".
Did you mean:
article_sub
2006 Jan 25
2
Update join_table attributes
...hat point at each other with a
"has_and_belongs_to_many" (habtm) relationship using a join table. The
join
table has an a few additional columns besides the _id columns.
For those of you with the Agile Web Dev w/ Rails book, it''s exactly the
same
setup as the articles<->articles_users<->users example on p240.
The habtm relationship is setup fine. I can see the linked data in
instances of the objects.
The problem, though, is that I can''t update the extra columns in the
join
table using update_attributes. This is a well documented shortcoming,
and
the solut...
2006 Mar 22
2
habtm vs. has_many/belongs_to
...an 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
real model
and decorate it with a richer set of behavior. This lets you
accompany the
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
return the
articles that have been read the most. This lightens t...