Hi Im new to Ruby On Rails, but have experience building iPhone apps. So far my iPhone apps have been built natively and they all have had a PHP back end. I simply used to invoke a PHP script from a Http request from the iPhone to communicate with the server.
Now I want to use RoR for the back end. However, RoR as a MVC architecture. The part thats confusing is, Since my “View” is not really a Html page, since its a native iPhone app, can I still use RoR as the back end. If so, then in place of the Html files in RoR’s folders what should I put, since there is no view to render. The only thing that I want the controller to do after it receives a HttP request from a client is respond with a JSON object to the iPhone.
ANy ideas/suggestions. Could someone please give me some links or names of books that deal with this scenario. I tried searching online, but couldn’t find this situation, maybe I was searching using the wrong keywords.
You won’t need the views at all for your iphone app. Your index action would have something like this…
in respons_do you see format.html would return your html view (if you don’t have a veiw just remove this line). The second line is what you are interested in. format.json will return a json response instead of rendering an html view. Calling http://example.com/posts.json would return your @posts as json.
You can see the full example here http://guides.rubyonrails.org/getting_started.html