Different behaviour on ActiveResorce with JSON or XML

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”=>“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”, “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”=>“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”,
“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?

Should it be better to post in the Rails Lighthouse?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs