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 :articles, :through => :comments
> 
> class Article < ActiveRecord::Base
>   has_many :comments
>   has_many :users, :through => :comments
> 
> class Comment < ActiveRecord::Base
>   belongs_to :users
>   belongs_to :articles

Wait.. what? A user has many articles through comments? Why, in the name 
of Yehuda Katz's beard, would you want to do that?
A user has many articles
A user has many comments
An article has many comments
An article belongs to a user
A comment belongs to an article
A comment belongs to a user.

Go from there, that's what makes sense.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to