[Rails] Re: Relationship Conventions

Tom Lianza
Mon, 24 Jul 2006 21:19:52 -0000

Patrice wrote:

> Just having a bit of trouble with the many-to-many relationship of the
> same type.
> Im trying to build a buddy list. So I have a users table and want to
> allow each user to have a buddlist of users.
>
> Ive tried having a User model and a Buddy model where the buddy model
> has 2 fields user_id and a buddy_id but i cant get the buddy.name
> methods to resolve when getting a list of buddies.
>
> Anyone know the convention for this type of setup?


I had a similar scenario, and I found this tip was right on:
http://wiki.rubyonrails.org/rails/pages/HowToCreateASelfReferentialManyToManyRelationship

Hope it helps,
Tom


--
Posted via http://www.ruby-forum.com/.