# ActiveRecord update\_attributes with nested hash

**URL:** <https://discuss.rubyonrails.org/t/activerecord-update-attributes-with-nested-hash/30448>\
**Category:** rubyonrails-talk\
**Created:** [June 10, 2008, 3:06pm UTC](https://discuss.rubyonrails.org/t/activerecord-update-attributes-with-nested-hash/30448 "2008-06-10T15:06:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [June 10, 2008, 3:06pm UTC](https://discuss.rubyonrails.org/t/activerecord-update-attributes-with-nested-hash/30448/1 "2008-06-10T15:06:16Z")

</div>

Can the parameter hash passed to update\_attributes include nested hashes for child models related through has\_many?

For example, if A has many B, can the parameter hash passed to A include a nested hash for B?

It seems the hash can include attributes for A e.g. one level deep.

Thanks for any advice....

---

<div class="post-metadata">

**Author:** ![Pardee\_Roy](https://avatars.discourse-cdn.com/v4/letter/p/f0a364/32.png) [@Pardee\_Roy](https://discuss.rubyonrails.org/u/Pardee_Roy)\
**Post date:** [June 10, 2008, 5:44pm UTC](https://discuss.rubyonrails.org/t/activerecord-update-attributes-with-nested-hash/30448/2 "2008-06-10T17:44:12Z")

</div>

Yes, but update\_attributes will look for a child\_hash\_name= method in your model. It'll pass in the child hash. Check out the "complex forms" railscasts--that goes over everything you need.
