# Different behaviour on ActiveResorce with JSON or XML

**URL:** <https://www.ruby-forum.com/t/different-behaviour-on-activeresorce-with-json-or-xml/166778>\
**Category:** Rails\
**Created:** [April 29, 2009, 2:00pm UTC](https://www.ruby-forum.com/t/different-behaviour-on-activeresorce-with-json-or-xml/166778 "2009-04-29T14:00:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pahagon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@pahagon](https://www.ruby-forum.com/u/pahagon)\
**Post date:** [April 29, 2009, 2:00pm UTC](https://www.ruby-forum.com/t/different-behaviour-on-activeresorce-with-json-or-xml/166778/1 "2009-04-29T14:00:23Z")

</div>

I’m doing a request from a Rails app to another Rails app with  
ActiveResource.

When the format on ActiveResource is XML:

Content.find(:all)[0,2].map(&:attributes)  
=\> [  
{“updated\_at”=\>Mon Apr 27 15:04:32 UTC 2009,  
“url”=\>“[www.google.com](http://www.google.com)”, “id”=\>1, “created\_at”=\>Mon Apr 27 15:04:32  
UTC 2009},  
{“updated\_at”=\>Tue Apr 28 14:48:55 UTC 2009,  
“url”=\>“[www.google.com](http://www.google.com)”, “id”=\>2, “created\_at”=\>Tue Apr 28 14:48:55  
UTC 2009}  
]

Nice and smooth.

But when it is JSON:

Content.find(:all)[0,2].map(&:attributes)  
=\> [  
{“content”=\>#\<Content:0x2040d10 @prefix\_options={}, @attributes=  
{“updated\_at”=\>“2009-04-27T15:04:32Z”, “url”=\>“[www.google.com](http://www.google.com)”,  
“id”=\>1, “created\_at”=\>“2009-04-27T15:04:32Z”}\>},  
{“content”=\>#\<Content:0x2040248 @prefix\_options={}, @attributes=  
{“updated\_at”=\>“2009-04-28T14:48:55Z”, “url”=\>“[www.google.com](http://www.google.com)”,  
“id”=\>2, “created\_at”=\>“2009-04-28T14:48:55Z”}\>}  
]

the problem is that to get an attribute in each Content object I have  
to do object.content.url instead of plain content.url.

Why is this happening? Is there any workaround?

---

<div class="post-metadata">

**Author:** ![pahagon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@pahagon](https://www.ruby-forum.com/u/pahagon)\
**Post date:** [April 30, 2009, 6:56pm UTC](https://www.ruby-forum.com/t/different-behaviour-on-activeresorce-with-json-or-xml/166778/2 "2009-04-30T18:56:54Z")

</div>

Should it be better to post in the Rails Lighthouse?
