Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveResource should handle multivalued attributes

#596

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:

--------8

>> u.find('Baptiste Grenier')

>> u.mail

=> ["plop@plop.org", "toglut@toglut.org"]

--------8

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:

--------8

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

plop@plop.org

toglut@toglut.org

hgPerson

inetOrgPerson

--------8

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:

--------8

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

ArgumentError: expected an attributes Hash, got "plop@plop.org"

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

--------8

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,

Baptiste

Ref:

[1]- http://tools.ietf.org/html/rfc2251

[2]- http://code.google.com/p/ruby-ac...

[3]- http://tools.ietf.org/html/rfc22....2.1

[4]- http://code.google.com/p/ruby-ac...

Reported by Baptiste Grenier · July 10th, 2008 @ 06:04 PM

State: stale
Milestone: 2.x
Assigned to: DHH DHH
Importance: none

Activity

  1. Pratik
    Pratik
    • State changed from new to stale
    • Tag changed from 2.1, activeresource, bug to 2.1, activeresource, bug

    October 12th, 2008 @ 08:28 PM