Forum: Ruby on Rails has_many (but parent & child should be same table )

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C5c0e0499446b84fd3bcc61cf7862539?d=identicon&s=25 Thani Ararsu (thaniyarasu)
on 2008-11-21 11:54
i have user table
each user have lots of friends
how to design ?
act_as_tree , will it work ?

any other suggestion appreciated.
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2008-11-21 20:36
(Received via mailing list)
> i have user table
> each user have lots of friends
> how to design ?
> act_as_tree , will it work ?

You could, but it would be messy since you and I could be friends so
who has many?

Start here:

http://agilewebdevelopment.com/plugins/search?search=friends

Find one that only requires a *single* row in the database to indicate
you and I are friends as opposed to "Philip is a friend of Thani"
*and* "Thani is a friend of Philip".

Last time I did this I used
http://agilewebdevelopment.com/plugins/has_many_friends
.  Worked well for me.

-philip
C5c0e0499446b84fd3bcc61cf7862539?d=identicon&s=25 Thani Ararsu (thaniyarasu)
on 2008-11-24 04:44
Philip Hallstrom wrote:


> http://agilewebdevelopment.com/plugins/search?search=friends
>
> Find one that only requires a *single* row in the database to indicate
> you and I are friends as opposed to "Philip is a friend of Thani"
> *and* "Thani is a friend of Philip".
>
> Last time I did this I used
> http://agilewebdevelopment.com/plugins/has_many_friends
> .  Worked well for me.
>
> -philip
Thanks
This topic is locked and can not be replied to.