On 22 January 2010 21:24, palidanx <[email protected]> wrote:
> Hi everyone,
>
> I have a model like the following
> User.id
>
> Friends
> invited (fk to user)
> inviter (fk to user)
>
> Now, what I would like to do is given a uid, retrieve all the users
> related to the inviter.  So a retarded way of oding hti sis..
>
> friendRequests =  Friend.find(:all, :conditions => {:invited_id =>
> uid})
>
> Then iterate through the friend requests, grabbing each user object..
>
> I know there is a better way of doing this in one query.. can I have
> some direction on doing this?

I don't understand fully the associations between the models, how have
you setup the has_many, belongs_to etc.

Can you be more explicit about what you mean by 'all the users related
to the inviter'?

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to