# Save / update related object

**URL:** <https://www.ruby-forum.com/t/save-update-related-object/156344>\
**Category:** Rails\
**Created:** [December 25, 2008, 2:08am UTC](https://www.ruby-forum.com/t/save-update-related-object/156344 "2008-12-25T02:08:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pauloee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d9b06d/32.png) [@pauloee](https://www.ruby-forum.com/u/pauloee)\
**Post date:** [December 25, 2008, 2:08am UTC](https://www.ruby-forum.com/t/save-update-related-object/156344/1 "2008-12-25T02:08:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pauloee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/d9b06d/32.png) [@pauloee](https://www.ruby-forum.com/u/pauloee)\
**Post date:** [December 25, 2008, 2:12am UTC](https://www.ruby-forum.com/t/save-update-related-object/156344/2 "2008-12-25T02:12:25Z")

</div>

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
