Re: current_user.friends.posts

Tyler McMullen
Thu, 24 May 2007 14:19:16 -0000

This little one liner should do it for you, if I''m not mistaken.

current_user.friends.map(&:posts)

which is equivalent to:

current_user.friends.map{|f| f.posts}


Tyler

On May 24, 12:46 am, Alex  Kroman
<alexkro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> Hi all,
>
> I have a pretty simple set of models.
>
> current_user has a bunch of friends and each friend makes a lot of
> posts.
>
> I want to do something like current_user.friends.posts but the posts
> method is missing.
>
> I''ve come up with a bunch of ways to accomplish this but nothing
looks
> very good.  What''s the most elegant way to do it?
>
> Thanks,
> Alex