<p>Relatively new to rails and trying to model a very simple family "tree" with a single Person model that has a name, gender, father_id and mother_id (2 parents). Below is basically what I want to do, but obviously I can't repeat the :children in a has_many (the first gets overwritten).</p>

<pre><code>class Person &lt; ActiveRecord::Base
  belongs_to :father, :class_name =&gt; 'Person'
  belongs_to :mother, :class_name =&gt; 'Person'
  has_many :children, :class_name =&gt; 'Person', :foreign_key =&gt; 'mother_id'
  has_many :children, :class_name =&gt; 'Person', :foreign_key =&gt; 'father_id'
end
</code></pre>

<p>Is there a simple way to use has_many with 2 foreign keys, or maybe change the foreign key based on the object's gender? Or is there another/better way altogether?</p>

<p>Thanks!</p>

I believe you can achieve the relationships you want using :has_one.
```
```
class Person < ActiveRecord::Base
  has_one :father, :class_name => 'Person', :foreign_key => 'father_id'
  has_one :mother, :class_name => 'Person', :foreign_key => 'mother_id'
  has_many :children, :class_name => 'Person'
end
```
```
I'll confirm and edit this answer after work ; )