inference?

I have the typical user, friendship model that does a has_many :through
Self-referential, exactly like this:

http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/

I have the following data in the friendships table

user_id = 5
friend_id = 10

User.find(5).friends gives me the user 10
User.find(10).friends gives me []

Is that right? Should I have two records for each friendship?

Thanks,

GP

I have the typical user, friendship model that does a has_many :through
Self-referential, exactly like this:

http://www.aldenta.com/2006/11/10/has_many-through-self-referential-example/

I have the following data in the friendships table

user_id = 5
friend_id = 10

User.find(5).friends gives me the user 10
User.find(10).friends gives me []

Is that right? Should I have two records for each friendship?

May want to consider using has_many_friends... really easy to setup, some nice helper methods tossed in as well...

http://agilewebdevelopment.com/plugins/has_many_friends

Greater point, thank you. The methods request/accept/etc work great at
the model level but when I try to expose that functionality through a
FriendshipsController unfortunately it seems to cause an infinit loop
and I end up with this in my development.log

  e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;35;1mUser Load (0.000000)e[0m e[0mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;35;1mUser Load (0.000000)e[0m e[0mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;35;1mUser Load (0.000000)e[0m e[0mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;35;1mUser Load (0.000000)e[0m e[0mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;35;1mUser Load (0.000000)e[0m e[0mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;35;1mUser Load (0.015000)e[0m e[0mSELECT * FROM `users` WHERE
(`users`.`id` = 11) e[0m
  e[4;36;1mUser Load (0.000000)e[0m e[0;1mSystemStackError: stack
level too deep: SELECT * FROM `users` WHERE (`users`.`id` = 11) e[0m
  e[4;35;1mUser Load (0.000000)e[0m e[0mRuntimeError: Packets out of
order: 1<>3: SELECT * FROM `users` WHERE (`users`.`id` = 11) e[0m

Philip Hallstrom wrote: