# From\_xml nested associations?

**URL:** <https://www.ruby-forum.com/t/from-xml-nested-associations/127770>\
**Category:** Rails\
**Created:** [February 1, 2008, 5:03am UTC](https://www.ruby-forum.com/t/from-xml-nested-associations/127770 "2008-02-01T05:03:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Corbin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58f4c7/32.png) [@Corbin](https://www.ruby-forum.com/u/Corbin)\
**Post date:** [February 1, 2008, 5:03am UTC](https://www.ruby-forum.com/t/from-xml-nested-associations/127770/1 "2008-02-01T05:03:14Z")

</div>

Does from\_xml work with nested associations? Meaning can I pass in a  
person object with associated addresses and have it correctly  
rehydrate the ActiveRecord model for person?

---

<div class="post-metadata">

**Author:** ![Corbin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58f4c7/32.png) [@Corbin](https://www.ruby-forum.com/u/Corbin)\
**Post date:** [February 1, 2008, 6:57pm UTC](https://www.ruby-forum.com/t/from-xml-nested-associations/127770/2 "2008-02-01T18:57:05Z")

</div>

Hi,

a quick look at the documented source:

(see  
[ActiveRecord::Serialization](http://api.rubyonrails.org/classes/ActiveRecord/Serialization.html#M001138))

128: def from\_xml(xml)  
129: self.attributes = Hash.from\_xml(xml).values.first  
130: self  
131: end

So it just sets attributes and does nothing with associations, it  
would appear.

Allan
