I have not used it, but acts_as_tree sounds like a good fit:
http://ar.rubyonrails.com/classes/ActiveRecord/Acts/Tree/ClassMethods.html
In your case, it would be a family tree :)
Tom
On 9/21/05, Jeroen Heijmans
<rails-navLQF7bQP5WbXBheyDZMNBPR1lH4CV8@public.gmane.org>
wrote:> Hi,
>
> I have a data structure similar to the following: Father has many
> Children, and Mother has many Children. When I load a Father, I
> immediately get access to his Children, but I cannot reach the Mother
> directly. I''ve solved this in two ways:
>
> 1) Load the Mother separately using the mother_id stored in a Child
> 2) Load the Mother together with a Child using the :joins parameter
> to the find function
>
> Both of them work fine, but I''m not very satisfied with them.
Option
> 1) needs an extra database query (even though it''s pretty basic),
> while 2) results in pretty ugly and fragile code. However, I can''t
> find any clues of another solution, not even in the "Agile Web
> Development with Rails" book.
>
> Is there a better way to solve this, or am I limited to the above
> options? Thanks in advance,
>
> Jeroen Heijmans
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>