I’ve created an API for Rails and now I want a Web Service (in this case PhoneGap) to talk to it. How would I do that?
Follpwing some instructions to getting the API down from these links (Rails API Versioning Screencast, Building a RESTful API using Rails 3 Screencast, Implementing a Public API in Rails 3, and Consuming a Public Rails API using jQuery) I’ve had trouble getting the PhoneGap App to get a successful callback from Rails. Here’s how I figured it out and perhaps someone will come along and improve my current method.
In the PhoneGap code I have an ajax call to the public API login for authentication (note, login/create is not really a RESTful word so it’ll have to be tweaked to). I pass in the email address and the password and upon success I should receive some data back and a pop up box:
Problem is even though I get this nice 200 OK message:
Ajax or PhoneGap is not happy and returns an error instead of a success when I use the respond_to block:
Not sure why that doesn’t work at the moment but what does work is the render callback: