ActiveRecord strange behavior


#1

Hi all,

I have a has_many relation between Parent and Child

Parent p
Child c

p.children << c => create the relationship in the database (why not
need
p.save to see the child add?)

why when i modifiy a field in c.how_old i have to explicity call to
c.save if
i want to see the modification in database (p.save doesn’t persist the
modification of chlild c)
because when i modify the child c and apply p.save it does nothing !!!

Other question Why p.children << c doesn’t need to do p.save to see c in
database. (<< operator already done it !!)

Regards

Croco


#2

Am Mittwoch, den 22.02.2006, 16:51 +0100 schrieb Luciano B.:

Other question Why p.children << c doesn’t need to do p.save to see c
in database. (<< operator already done it !!)

Because the foreign-key sits in the children table and therefor only
this one needs an update. A save on the parent won’t have any affect.

Norman T.

http://blog.inlet-media.de