I have built a web service to allow people to query and manipulate my ActiveRecord data.
:expects => [:int],
:returns => [Widget]
works fairly well, since it returns my ActiveRecord “widget” class - no mess, no fuss, no hassle, no repetition.
The only problem is, this class interacts with several other objects:
would ideally like to return the entire object hierarchy as a SOAP or
XML-RPC object. I have tried this in my service controller:
def find_widget_by_id( id )
Widget.find( id, :include => [:associatedthings] )
it still just returns the “Widget” object without any of the
“associatedthing” objects. I have tried it with one of the
“belongs_to” objects as well, and the results are the same. Has anyone
done this before? Is there any kind of Rails magic to do this, or
should I build some custom return classes and shove all the data into
those? I’m trying to follow the “DRY” principle in order to keep this
as simple as possible, even though the brute force option would work.