I have 3 models comments(user_id, title) followings(user_id, follower_id) users(email)
I need to find all comments made by people that a user is following, which in effect is this simple SQL query: select comments.title from comments, followings, users where users.id = followings.follower_id and followings.user_id = comments.user_id and users.id = 1 Can someone help? I tried this but it didn't work: class User ... has_many :followings class Following ... has_many :comments, :foreign_key => 'user_id' script/console User.find(:first).followings (this works) Following.find(:first).comments (this works) User.find(:first).followings.comments (this does NOT work) --~--~---------~--~----~------------~-------~--~----~ 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-talk@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 -~----------~----~----~----~------~----~------~--~---