Maulin pa wrote:
Here is the scenario, Articles have many Comments Users can write many
Comments for many Articles
The comments table contains both
user_id
article_id
as foreign keys
My models are set up like so
class User ActiveRecord::Base
has_many :comments
has_many
Haha! The beard bit made me laugh :)
Well, in my model articles dont have a user association. They just
have comments and users can post comments to different articles
So basically article and user have a many to many relationship with
the comments being the join table (it contains both
Maulin pa wrote:
Well, in my model articles dont have a user association. They just
have comments and users can post comments to different articles
Okay, so we have:
Article has many comments
Comment belongs to article
Comment belongs to user
User has many comments
So basically article
*blink* Yes, but no. I mean.. Yes, but no! You're abusing the concept of
the many:many relationship. As long as you're aware of that, let's move
on...
Since the comments table has both the article and user id's it just
lends itself to be thought of that way, dont you think?
What else would you
Maulin pa wrote:
The user_article_comment_path([...@user, @article])
will point to the new action in the comment controller and rails
knows to use user_id and article_id from the [...@user, @article]
In other words, you want to create a new many-to-many relationship ?
Your problem is that
5 matches
Mail list logo