RailsCasts Pro episodes are now free!

Learn more or hide this

Cynthia Kiser's Profile

GitHub User: cnk

Comments by Cynthia Kiser

Avatar

I was having the same problem as comments #19 and 20 with custom query methods returning hashes rather than objects. I didn't find what I was looking for in the online docs, but looking at activeresource-2.3.5/lib/active_resource/base.rb line 544 I found a :from option to find. Using the syntax from the provided examples, I can get back a collection of objects from a custom query. The custom query just needs to send back a naked array of valid JSON objects. For example:

 [{"name": "John", "position": 1}, {"name": "Jane", "position": 2}]

Person.find(:all, :from => "/companies/1/people.xml")