# Has\_many self references

**URL:** <https://www.ruby-forum.com/t/has-many-self-references/92456>\
**Category:** Rails\
**Created:** [April 19, 2007, 5:59pm UTC](https://www.ruby-forum.com/t/has-many-self-references/92456 "2007-04-19T17:59:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fozbaca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f0a364/32.png) [@fozbaca](https://www.ruby-forum.com/u/fozbaca)\
**Post date:** [April 19, 2007, 5:59pm UTC](https://www.ruby-forum.com/t/has-many-self-references/92456/1 "2007-04-19T17:59:56Z")

</div>

I am trying to model families in a database for tax and other purposes,  
and am probably trying to hard. I setup a people table and a base class  
person with  
name, address, date of birth,etc. Then I create classes of  
husbands,wives, children that are all of the person class, and all are  
mapped onto the single people table. obviously these are  
self-referencing  
tables, but I having trouble with the has\_many, belongs\_to  
relationships. I think I am confusing rails to some degree. It would  
seem that these would be easy to model, but being a part-time  
programmer, I am having troubles. when I use the  
has\_many (for children) and has\_one (for husband,wife) I cannot get  
rails to  
consistently persist those relationships. I’m also using different names  
for the relationship than the class (i.e. belongs\_to :father,  
:class\_name =\> “Husband”, foreign\_key =\> “father”). I realize that I  
don’t have a full handle on how to do this more simply. (or how not to  
confuse rails). can anybody point me in the right direction?
