gow
June 28, 2007, 8:07am
#1
hi every one,
i’m new to ruby on rails.so, need some help.
my project is that a user can add friends to his profile where friends
are users themselves.
i thought of creating two tables one for users and other for
user_friends.i don’t know how to relate these two tables so that they
serve my purpose.
any suggestions plz.
thanks in advance.
gow
June 28, 2007, 8:50am
#2
I am also new but I think you just need to add to Users model:
has_and_belongs_to_many :users.
gow
June 28, 2007, 9:51am
#3
check out self referential associations - it is exactly what you are
looking for.
the problem with doing has_and_belongs_to_many :users, is that you will
still need a join table that ‘holds’ these associated records.
give it time, it looks daunting at first, but it works.
a couple links:
i worked with this
http://lists.rubyonrails.org/pipermail/rails/2006-February/021193.html
anyway … check out google for self_referential; that’s the way to go.
hope this helps!
shai
gow
June 29, 2007, 6:04am
#4
thank u russian for the reply.
i did add has_and_belongs_to_many :users. to User model.
gow
June 29, 2007, 6:08am
#5
thank u shai
the urls u send were really helpful.i got great deal of relevant stuff
from those links.
On Jun 28, 12:51 pm, Shai R. [email protected]