Forum: Ruby on Rails Different behaviour on ActiveResorce with JSON or XML

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Paulo P. (Guest)
on 2009-04-29 16:00
(Received via mailing list)
I'm doing a request from a Rails app to another Rails app with

When the format on ActiveResource is XML:

=> [
  {"updated_at"=>Mon Apr 27 15:04:32 UTC 2009,
"url"=>"", "id"=>1, "created_at"=>Mon Apr 27 15:04:32
UTC 2009},
  {"updated_at"=>Tue Apr 28 14:48:55 UTC 2009,
"url"=>"", "id"=>2, "created_at"=>Tue Apr 28 14:48:55
UTC 2009}

Nice and smooth.

But when it is JSON:

=> [
  {"content"=>#<Content:0x2040d10 @prefix_options={}, @attributes=
{"updated_at"=>"2009-04-27T15:04:32Z", "url"=>"",
"id"=>1, "created_at"=>"2009-04-27T15:04:32Z"}>},
  {"content"=>#<Content:0x2040248 @prefix_options={}, @attributes=
{"updated_at"=>"2009-04-28T14:48:55Z", "url"=>"",
"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?
Paulo P. (Guest)
on 2009-04-30 20:56
(Received via mailing list)
Should it be better to post in the Rails Lighthouse?
This topic is locked and can not be replied to.