Forum: Ruby on Rails a child object saved to database just by appending to a pare

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E320f4a0b0ece6655b1d83cdb8d47a20?d=identicon&s=25 Kye (Guest)
on 2007-02-27 17:49
(Received via mailing list)
Hi all,

I just observed an unexpected behavior of saving. I need some help.
I am using Rails 1.2 and mysql 5.xx.

I created a child object, then appended to a parent object. That is,

child = Child.new
parent.children << child

Before I do, parent.save, I looked at the database table.
this child object row is alredy created there in the child table.

The relationship is quite simple

Parent
has_many :children

Child
belongs_to :parent, :dependent => :nullify

Thank you for any comment

Kye
This topic is locked and can not be replied to.