Topic: Rails - Consuming local JSON API from another controller

Hi,

I am building an App that serves as the backend for an android app as well as a rails webapp. To serve as a back end, I have built a series of api controllers ( ex: api_users contoller with actions show, update etc.) which will return a JSON/ XML output (using RABL).

In my Webapp, when it is time to update the User profile say, I simply want to call the update action of the api_users controller and parson the json output in my User's controller, parse this output and then handoff the data to my view etc. How do I go about making such calls?

A very bad workaround seems to be to treat it like any external API and call it using Net::Http etc. It seems really strange that I should be able to consume an external api easily but not my local API. Can somebody help/ guide me to the recommended way of doing this?

Thanks,

Ramkumar.

Re: Rails - Consuming local JSON API from another controller

Your question isn't really very clear.
You would be calling the update action in your api namespace from your android app. so you would just render a rabl template,
If you are updating a users  credentials from withing your web app then that would be done through an admin namespace and would have the full CRUD actions in the users controller locked down by an admin user name and password.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)