rails inverting to_xml and getting the original model

Posted by djacobs7 on Stack Overflow See other posts from Stack Overflow or by djacobs7
Published on 2010-03-24T01:04:55Z Indexed on 2010/03/24 1:13 UTC
Read the original article Hit count: 481

Filed under:
|
|
|

I did this:

[User.first, User.last].to_xml

and got this:

<users type="array">
   <user>
     <created-at type="datetime">2010-03-16T06:40:51Z</created-at>
     <id type="integer">3</id>
     <password-hash></password-hash>
     <salt></salt>
     <updated-at type="datetime">2010-03-16T06:40:51Z</updated-at>
     <username nil="true"></username>
   </user>
   <user>
     <created-at type="datetime">2010-03-23T03:58:15Z</created-at>
     <id type="integer">7</id>
     <password-hash></password-hash>
     <salt></salt>
     <tutorial-state nil="true"></tutorial-state>
     <updated-at type="datetime">2010-03-23T03:58:15Z</updated-at>
     <username nil="true"></username>
   </user>
</users>

How can I take that string of xml and invert it to get the original activerecord objects back?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about rails