Forum: Ruby on Rails Find question

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.
4bfccddd9228cc2e8a00005af679475a?d=identicon&s=25 John Burm (funbags)
on 2007-04-19 20:31
Hello All,

Quick find question for you, I have a comments, users and a friends

The user model has_many :friends, :through => :friendships

How can I include the friends comments in a find? (I know the below does
not work, it just pulls up the @user's comments) but if i substitute in
([@user, 4, ... It works fine pulling in the's comments and the
user who's ID is 4 in as well.

@comments = Comment.find_all_by_user_id([@user, @user.friends],
                                          :include =>
                                          :order  => " DESC",
                                          :limit  => "10")

Thank you in advance,
 - John
This topic is locked and can not be replied to.