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 Abreu

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?

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

Fred