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?
thanks!
-dan
On 22 January 2010 21:24, palidanx [email protected] wrote:
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