Consuming local JSON API from another controller
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. Can somebody help/ guide me to the recommended way of doing this?
Thanks,
Ramkumar.
Since I did not find any simple way to do this, I decided to treat it like an external api. Only instead of going all the way to the dns and back, I decided to simply call it using off of localhost.
链接地址: http://www.djcxy.com/p/45644.html上一篇: 服务器端渲染/模板
下一篇: 从另一个控制器消费本地JSON API