Save / update related object

Imagine that I have the following objects:

class Person < ActiveRecord::Base
has_one :nose
end

class Nose < ActiveRecord::Base
end

p = Person.new
p.name = “Mary”
p.nose = Nose.new
p.save

p.nose.colour = “white”
p.save

Why in the last p.save, p.nose.colour is not persisted in database? Is
there any way of doing this in an automatic way?

Regards,

Paulo A.

On 25 Dec 2008, at 01:08, Paulo A. wrote:

p = Person.new
p.name = “Mary”
p.nose = Nose.new
p.save

p.nose.colour = “white”
p.save

Why in the last p.save, p.nose.colour is not persisted in database? Is
there any way of doing this in an automatic way?

Because p.save only saves child objects if they are unsaved.

Fred