# Update only the object, but not nested attributes?

**URL:** <https://www.ruby-forum.com/t/update-only-the-object-but-not-nested-attributes/188720>\
**Category:** Rails\
**Created:** [May 17, 2010, 9:32am UTC](https://www.ruby-forum.com/t/update-only-the-object-but-not-nested-attributes/188720 "2010-05-17T09:32:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrmanishs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/51bf81/32.png) [@mrmanishs](https://www.ruby-forum.com/u/mrmanishs)\
**Post date:** [May 17, 2010, 9:32am UTC](https://www.ruby-forum.com/t/update-only-the-object-but-not-nested-attributes/188720/1 "2010-05-17T09:32:52Z")

</div>

I have a situation where I only want to update the object, but not the  
nested attributes. Is there a way to tell Rails to only call  
update\_attributes on the main object? I also have a situation where I  
only wanted to update certain nested attributes, but not the main  
object (i.e. one of the subobject attributes of the main object).

Thanks.

---

<div class="post-metadata">

**Author:** ![mrmanishs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/51bf81/32.png) [@mrmanishs](https://www.ruby-forum.com/u/mrmanishs)\
**Post date:** [May 17, 2010, 3:56pm UTC](https://www.ruby-forum.com/t/update-only-the-object-but-not-nested-attributes/188720/2 "2010-05-17T15:56:52Z")

</div>

Update attributes just calls attributes=, which just calls the setter  
methods corresponding to the args hash keys. Thus, the way to do what  
you’re looking for is to delete the hash keys you don’t want.

But for updating a subrecord instead, you could just call  
update\_attributes on the subrecord instead of the main record.
