Well, actually, “complex finds” to me because I can’t figure how.
I have this app where I have two basic models: user and post.
There is also a model ‘friendship’. This basically belongs_to :user, and
belongs_to :friend (with :class_name=>‘User’). This model basically
the friends whose posts the given user wants to follow.
So to find a particular friend’s posts, I do posts =
Now, I want to find ALL my friends’ recent posts (with a created_at
or simply the latest 5 posts etc).
How do I do that? Obviously, I can look through each friend’s posts,
get the 5 most recent posts (by created_at), but then if I have a lot of
friends, it means a lot of useless database queries.
Is there a better way? Someone recommended trying to do it with SQL JOIN
a)I don’t know SQL well, b)I like ActiveRecord’s warm, fuzzy feel.
View this message in context:
Sent from the RubyOnRails Users mailing list archive at Nabble.com.