Hello,
Don't know if this will help or not, but In the Active Record docs
there
is an ‘act as tree’ which works as a one to many on itself. It has allot
of
info about how this is done in the modal, you could most likely get some
ideas from that as well.
Chanan Braunstein
Knovel Corp.
Web D. Manager
607-773-1840 x672
http://www.knovel.com
From: [email protected]
[mailto:[email protected]] On Behalf Of Liquid
Sent: Monday, November 14, 2005 9:36 AM
To: [email protected]
Subject: Re: [Rails] challenge
There is a good article on this on the wiki
http://wiki.rubyonrails.com/rails/pages/HowToCreateASelfReferentialManyToMan
yRelationship
<Peak Obsession
nyRelationship>
Maybe this will help
Cheers
On 11/15/05, allenbobo [email protected] wrote:
i love ROR. but i met a problem :
i have a table:
users
id int not null,
name varchar(100)…
and i want create a friends association, seems many-to-many
self-referential
i create a friends table:
user_id int not null,
friend_id int not null,
constraint fk_fu_user foreign key (user_id) references users(id),
constraint fk_fu_friend foreign key (friend_id) references users(id)
…
the user Model contains
has_many :friends
the friend Model contains
belongs_to :user
i hope it’s ok ,but when i test it allways:
“Couldn’t find Firend without a ID”
so, guys, if you know what’s goning on, please give a hand.
all regards