Rails makes this really easy, really. By default, it provides XML endpoints. You can expose JSON just as easily (and, for iPhone, you should use JSON as it is easier to parse). Plus, he does it RESTfully. You should not add an API controller - just use the controllers that you already have for your resources.
In your block, respond_toyou should already see the code for XML. For JSON, just add the following:
format.json { render :json => @item, :status => :created, :location => @item }
Grab this something like RestKit on the iPhone, and you can easily create an iPhone application that communicates with the Rails application.
source
share