# Validates\_associated trouble

**URL:** <https://www.ruby-forum.com/t/validates-associated-trouble/86285>\
**Category:** Ruby\
**Created:** [February 21, 2007, 4:25am UTC](https://www.ruby-forum.com/t/validates-associated-trouble/86285 "2007-02-21T04:25:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alfredogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@alfredogz](https://www.ruby-forum.com/u/alfredogz)\
**Post date:** [February 21, 2007, 4:25am UTC](https://www.ruby-forum.com/t/validates-associated-trouble/86285/1 "2007-02-21T04:25:08Z")

</div>

Hello,

I need to modelate a genealogical tree with:  
animal,Dam(Mother) and Sire(Father)

the Dam and Sire are Animals then i modelate this:

class Animal \< ActiveRecord::Base  
belongs\_to :sire  
belongs\_to :dam  
validates\_associated :sire, :dam  
end

class Sire \< Animal  
has\_many :animals  
end

class Dam \< Animal  
has\_many :animals  
end

then when i save a new animal the validate doesnt work like this:

i have the table Animals

ID, Name Father MOther  
1 A - -  
2 B - -

when I insert a new record like this

insert(3,C,1,2) its ok!  
insert(3,C,5,7) its ok too, (the validates is doesnt work)

how can i solve this??

---

<div class="post-metadata">

**Author:** ![alfredogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@alfredogz](https://www.ruby-forum.com/u/alfredogz)\
**Post date:** [February 21, 2007, 10:34am UTC](https://www.ruby-forum.com/t/validates-associated-trouble/86285/2 "2007-02-21T10:34:10Z")

</div>

On Wed, 21 Feb 2007 04:25:11 +0100, Alfredo G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> [snip] ActiveRecord::Base [snip]

Try the Rails mailing list  
[[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)] for this.

Also, I’m so ripping off the word “modelate”.

David V.
