Forum: Ruby on Rails Relationships in Rails...

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ead43bcb0202410540a6a7cee5955d46?d=identicon&s=25 Fresh Mix (giga)
on 2009-01-26 10:18
I have 2 tables:

people (id, name)
children (id, parents_id, child_id)

parents_id = and child_id = people_id also

So how I make a relationships in Rails?

And how can all search:

Children.find(:all, :conditions => [" LIKE 'Clin%' ???? Or

And what if I want to add new child. Parents name is in people table,
but childs not, so how I do?
Beeca027396982f7ba3ced79193e5199?d=identicon&s=25 Martin Hawkins (Guest)
on 2009-01-26 10:51
(Received via mailing list)
Sounds like a many to many relationship, in which case you need to
declare has_and_belongs_to_many on both people and children. The
relationship then works through a join table. If you did this, you'd
need to re think your model a little and your find and add problems
would be different.

On Jan 26, 9:18 am, James Bond <>
8c639c73cd3f657683b05bc2da9fc7ea?d=identicon&s=25 Juan José Vidal (Guest)
on 2009-01-26 12:50
(Received via mailing list)
I think that the best solution to your problem is to use acts_as_tree

Martin Hawkins
escribió:> Sounds like a many to many relationship, in which case you need to
This topic is locked and can not be replied to.