Forum: Ruby on Rails Conflicting Attributes in Model and Join Table...

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bradley M. (Guest)
on 2006-03-16 16:47
(Received via mailing list)
Hi all,

I've got a Post and User classes.  The Post has a user_id attribute to
point to the user that created it.

I want to implement favorites, so I made Post and User both
"has_and_belongs_to_many" and created a favorites join table.  The
join table has a post_id and a user_id column.

Now when I get my post everything seems to be okay, but in some
contexts, the user_id get's overwritten.  I think that the user_id
from the join table is being merged into my Post instance.

What would you do differently so that there was no collision between
my Post's user_id (the author) and the join table's user_id (for whom
this post is a favorite)?

Bradley M.
This topic is locked and can not be replied to.