This project is archived and is in readonly mode.

#596 ✓stale
Baptiste Grenier

ActiveResource should handle multivalued attributes

Reported by Baptiste Grenier | July 10th, 2008 @ 06:04 PM | in 2.x

I am using ActiveResource to access a RESTfull WebService exposing LDAP[1] resources through the usage of ActiveLdap[2].

LDAP attributes[3] could be multivalued and some of them are often (objectClass or email as an example).

The ActiveLdap object represents this values as an array:


>> u.find('Baptiste Grenier')

>> u.mail

=> ["", ""]


I have contacted[4] the helpful ActiveLdap team in order to change the xml outputed by the to_xml method, and here is an extract of what the to_xml now produces:


cn=Baptiste Grenier,ou=people,dc=plop,dc=org




But this does not make things works better with ActiveResource, as when I try to create a ActiveResource object from this resource, I get this error:


>> u = User.find('50')

ArgumentError: expected an attributes Hash, got ""

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:883:in `load'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:639:in `initialize'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:890:in `new'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:890:in `load'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:890:in `map'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:890:in `load'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:885:in `each'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:885:in `load'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:639:in `initialize'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:587:in `new'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:587:in `instantiate_record'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:579:in `find_single'

from /usr/lib/ruby/gems/1.8/gems/activeresource-2.1.0/lib/active_resource/base.rb:507:in `find'

from (irb):13


Perhaps if ActiveResource could be aware of a multivalued type (used in the to_xml like the array type) and then create an attribute as an array, it could be possible to handle such a situation.

Thanks for any help,







Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>