Re: current_user.friends.posts

Gabe Da silveira
Thu, 24 May 2007 04:57:45 -0000

Create the posts method yourself by extending the association:

has_many :friends do
  def posts
    #get posts here
  end
end

See the Association Extensions in the api docs for a few variables that
you might need to make that work.


Alex Kroman 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



--
Posted via http://www.ruby-forum.com/.