fabrik42/acts_as_api — Issue #41: Render into variable?
Author: tylercollier
Created: 2011-10-20 19:36:19+00:00
State: open

I'm sorry, this is not so much an issue as a simple question but I didn't find any links to any forums, etc, so I'm posting here. Please inform me if there is such a place.

I just want to be able to reuse the data exposed by this acts_as_api concept. There is the "name_only" example of a template. How could I get a JSON or XML representation of my model object for the "name_only" example?

I want to do something simple like this:

object_as_json = @object.get_acts_as_api_data(:template => :name_only, :format => :json)

(I understand that one of the benefits with acts_as_api is that you don't have to explicate json vs xml (vs others) in the controller, but explicitly doing so in my situation is fine.)

My real world situation here is that I'm testing. I'm simulating data coming from an external system with a certain representation, and it'd be great if I could reuse the data exposed by the api templates.