# Why can't active resource deserialize this xml response?

**URL:** <https://www.ruby-forum.com/t/why-cant-active-resource-deserialize-this-xml-response/124551>\
**Category:** Rails\
**Created:** [December 30, 2007, 4:25am UTC](https://www.ruby-forum.com/t/why-cant-active-resource-deserialize-this-xml-response/124551 "2007-12-30T04:25:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggie5](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7c8e57/32.png) [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Post date:** [December 30, 2007, 4:25am UTC](https://www.ruby-forum.com/t/why-cant-active-resource-deserialize-this-xml-response/124551/1 "2007-12-30T04:25:17Z")

</div>

Can anybody explain why active resource can’t deserialize this?

Active Resource class:

class Pownce \< ActiveResource::Base  
self.site = “[http://api.pownce.com/1.0](http://api.pownce.com/1.0)”  
end

class User \< Pownce  
end

Command I’m using:

User.find(:all, :from =\> ‘/users/eggie5/friends.xml’)

Resolves to this:

GET [http://api.pownce.com:80/users/eggie5/friends.xml](http://api.pownce.com:80/users/eggie5/friends.xml)  
 → 200 OK (\<?xml version="1.0" encoding="utf-8"?\>  
  
  
casseeee  
[http://pownce.com/casseeee/](http://pownce.com/casseeee/)  
\<short\_name\>cassee a.\</short\_name\>  
United States  
20  
\<first\_name\>cassee\</first\_name\>  
  
Lady  
\<profile\_photo\_urls\>  
\<smedium\_photo\_url\>[http://pownce.com/profile\_photos/c/a/s/](http://pownce.com/profile_photos/c/a/s/)  
casseeee/31250\_smedium.jpg\</smedium\_photo\_url\>  
\<small\_photo\_url\>[http://pownce.com/profile\_photos/c/a/s/](http://pownce.com/profile_photos/c/a/s/)  
casseeee/31250\_small.jpg\</small\_photo\_url\>  
\<tiny\_photo\_url\>[http://pownce.com/profile\_photos/c/a/s/](http://pownce.com/profile_photos/c/a/s/)  
casseeee/31250\_tiny.jpg\</tiny\_photo\_url\>  
\<medium\_photo\_url\>[http://pownce.com/profile\_photos/c/a/s/](http://pownce.com/profile_photos/c/a/s/)  
casseeee/31250\_medium.jpg\</medium\_photo\_url\>  
\<large\_photo\_url\>[http://pownce.com/profile\_photos/c/a/s/](http://pownce.com/profile_photos/c/a/s/)  
casseeee/31250\_large.jpg\</large\_photo\_url\>  
\</profile\_photo\_urls\>  
\<is\_pro\>0\</is\_pro\>  
  
  
  
elagothro  
[http://pownce.com/elagothro/](http://pownce.com/elagothro/)  
\<short\_name\>Michael O.\</short\_name\>  
United States  
22  
\<first\_name\>Michael\</first\_name\>  
PHP/MySQL Dev Lead for foliopod ( [http://chicagofolio.com](http://chicagofolio.com)  
& [http://foliopod.com](http://foliopod.com) ) and CareerNoodle ( [http://careernoodle.com](http://careernoodle.com)  
)  
Dude  
\<profile\_photo\_urls\>  
\<smedium\_photo\_url\>[http://pownce.com/profile\_photos/e/l/a/](http://pownce.com/profile_photos/e/l/a/)  
elagothro/96840\_smedium.jpg\</smedium\_photo\_url\>  
\<small\_photo\_url\>[http://pownce.com/profile\_photos/e/l/a/](http://pownce.com/profile_photos/e/l/a/)  
elagothro/96840\_small.jpg\</small\_photo\_url\>  
\<tiny\_photo\_url\>[http://pownce.com/profile\_photos/e/l/a/](http://pownce.com/profile_photos/e/l/a/)  
elagothro/96840\_tiny.jpg\</tiny\_photo\_url\>  
\<medium\_photo\_url\>[http://pownce.com/profile\_photos/e/l/a/](http://pownce.com/profile_photos/e/l/a/)  
elagothro/96840\_medium.jpg\</medium\_photo\_url\>  
\<large\_photo\_url\>[http://pownce.com/profile\_photos/e/l/a/](http://pownce.com/profile_photos/e/l/a/)  
elagothro/96840\_large.jpg\</large\_photo\_url\>  
\</profile\_photo\_urls\>  
\<is\_pro\>1\</is\_pro\>  
Chicago, IL

It’s simply a collection of 2 User objects. Can somebody enlighten me  
as to why this won’t deserialize? This is the error:

NoMethodError: undefined method `collect!' for #<Hash:0x12a86bc> from /usr/local/lib/ruby/gems/1.8/gems/activeresource-2.0.2/lib/ active_resource/base.rb:465:in `instantiate\_collection’  
from /usr/local/lib/ruby/gems/1.8/gems/activeresource-2.0.2/lib/  
active\_resource/base.rb:439:in `find_every' from /usr/local/lib/ruby/gems/1.8/gems/activeresource-2.0.2/lib/ active_resource/base.rb:385:in `find’

---

<div class="post-metadata">

**Author:** ![eggie5](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7c8e57/32.png) [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Post date:** [December 30, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/why-cant-active-resource-deserialize-this-xml-response/124551/2 "2007-12-30T16:23:54Z")

</div>

try to change to

using this

xml.users(:type =\> ‘array’)

[http://dev.rubyonrails.org/ticket/8798](http://dev.rubyonrails.org/ticket/8798)

* * *

Ettore

---

<div class="post-metadata">

**Author:** ![eggie5](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7c8e57/32.png) [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Post date:** [December 30, 2007, 7:57pm UTC](https://www.ruby-forum.com/t/why-cant-active-resource-deserialize-this-xml-response/124551/3 "2007-12-30T19:57:38Z")

</div>

Doesn’t this effectively exclude any non-rails webservice from being  
used with active resource?

Is this just acceptable to you?

On Dec 30, 7:23 am, Ettore B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![eggie5](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7c8e57/32.png) [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Post date:** [December 30, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/why-cant-active-resource-deserialize-this-xml-response/124551/4 "2007-12-30T19:59:58Z")

</div>

This isn’t a rails webservice, so I can’t make those edits. This isn’t  
a standard of rest or anything…

On Dec 30, 7:23 am, Ettore B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
