Re: ActiveRecord bottom half

Perry Smith
2007-07-07T19:35:36Z

Bill Walton wrote:
> Hi Perry,
>
> What you don''t say in your post above is whether or not
you''re getting
> the
> results you expect.

I thought I did.  The validates_presence_of always produces an error.

I''m trying to make sure that the child and parent have been set and are
not null.

At the time validate gets called, child_id and child_type are not set
(according to my logging). But they get set before they actually get
saved.

The relationship is being saved because I have appended it to
@person.children. i.e.

    @person.children << relationship (as you can see in my other post).

So, somehow, before the data actually is shipped off to the database but
after the validation sequence, the child_id and child_type get filled
in.

I''m still trying to debug this and find a way to get this to work.  I
thought I had it figured out but the last test didn''t work.

Oh, also, if I do both:

    @person.children << relationship
    relationship.child = @person

that causes an infinite recursion.

This seems pretty basic.  I must be doing something really silly but I
don''t know what it is.