I have an app where users have friends, and friends can have messages
for friends to see. I would like to list all the messages that my
friends have easily.
I can use @user_friends = current_user.friends to find all my friends
and then I could loop through the friends to get each friend's messages
to place them in some array of messages I guess.
But, is there a simpler way to get that list of messages?
I'm a bit worried about the performance side of that request since there
can be a huge number of messages and users. Of course user_id should be
indexed in that table but I'm still worried.
this is still teh fastest way to do it since you are telling the db
fetch all of these ids at once.
Then again,
Don't worry about it until it's a problem
is kinda the best advice in the matter if you add. "or untill you are
finished, have done profiling and are bored of tv"