Forum: Ruby validates_associated trouble

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
51bb5688c8c2c1b68d03c56da8e0b696?d=identicon&s=25 Alfredo Gama (alfredogz)
on 2007-02-21 04:25

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

class Sire < Animal
  has_many :animals

class Dam < Animal
  has_many :animals

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??
430ea1cba106cc65b7687d66e9df4f06?d=identicon&s=25 David Vallner (Guest)
on 2007-02-21 10:34
(Received via mailing list)
On Wed, 21 Feb 2007 04:25:11 +0100, Alfredo Gama <>

> [snip] ActiveRecord::Base [snip]

Try the Rails mailing list
[] for this.

Also, I'm so ripping off the word "modelate".

David Vallner
This topic is locked and can not be replied to.