belongs_to :mother, :class_name => "Person"
has_many :children, :foreign_key => :mother_id, :class_name =>
"Person"

I believe that should give the behavior you're after though untested
and from memory.  Check the rails docs for active record to make sure
the syntax is right if it gives problems.

On May 27, 4:08 pm, Togg <[email protected]> wrote:
> Hi all,
>
> I need some hints and suggestions on setting up a correct self-
> reference table relationship.
> The database is populated externally with text data, and I want to use
> only this data to declare the parent-child relationship.
> Assuming we have following pseudo structure for a person. It also
> includes the name of the mother as "first_name last_name"
>
> class Person < ActiveRecord::Base
>   hobo_model
>
>   fields do
>     first_name :string
>     last_name :string
>     mother      :string
>   end
>
> belongs_to :mother
> has_many :childs, :finder_sql => "select * from persons where mother =
> "#{first_name} #{last_name}""
>
> Would be nice to get some ideas, hopefully circumventing a has_many
> childs :through parentship relationship!
>
> Thanks,
> Sebastian

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to