ActiveResource - Two simple questions

Samuel Richardson
2009-09-09T23:10:29Z

I''m struggling a bit with implementing ActiveResource on a custom
RESTful API.

Firstly, I can''t seem to disable the transforms it does when it parses
the XML. For example "CamelCase" gets rendered as camel_case, likewise
underscores get converted to dashes. The docs page for ActiveResource
mentions being able to set

ActiveSupport.camelise_xml = false

In an initializer to disable this. This throws an error. I think I can
get around the naming problems by converting the hash into XML with
the correct formatting then back into a hash again. This seems crazy.

Secondly, when constructing forms using form_for on ActiveResource
objects, it throws a method not found because it has not loaded a
schema for the ActiveResource (unlike ActiveRecord). To get around
this, I''ve patched ActiveResource to return nils no methods that are
not found, however I''ve run into a further problem with nested
resources, for example:

contacts.phones.home

Throws a method not found on the home. How can I get around this? How
can I manually construct an ActiveResource object to include this
child nodes so I can wrap form_for around them.

Sam