Should it be better to post in the Rails Lighthouse?
On Apr 29, 12:59 pm, Paulo Pereira <[email protected]> wrote:
> 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", "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.find(:all)[0,2].map(&:attributes)
> => [
> {"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?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---