I am developing my first iOS (using 7.0) app. i want to send and retrieve data from a database on a remote server. The remote server is hosted by my web hosting company. they use LAMP stack. How can I use Ruby on Rails to add and retrieve data from the remote database? is there any book/website/tutorial that gives a clear solution?
API
Although I've yet to design this myself, I know that RoR apps tie into iOS through an API . If you wish to transfer data to/from your rails app, you'll be best making an authenticated API, like this:
#config/routes.rb
namespace :api do
resources :controller
end
#app/controllers/api/your_controller.rb
module Api
class YourController < ApplicationController
respond_to :json
def xxx
end
end
end
This is a very basic representation of what you'll have to do to create a JSON-powered "api" for a Rails app, which you'll be able to use to communicate with your database.
Some caveats to this include that you'll need to authenticate any request:
--
There's a good technical overview here :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.