Repository navigation
Introduction
I have to tell you that my experience with mobile app development is limited to the iOS platform. However, what we'll discuss tonight should be applicable to any mobile platform, and probably any client application.
With that said I want to walk you through the process of building a Rails app from scratch that will serve as a backend for a mobile application. This will be an API-only Rails app, meaning it will only respond to JSON requests to be consumed by the client outside of the rails stack. In a general sense, our client could be a desktop app or even another web app. Since we're focusing on mobile device clients, one of our concerns is data consumption. That's a big motivation for using JSON as opposed to XML. Another benefit of JSON is that any client platform should have tools readily available to send JSON requests and to consume JSON responses. This is opposed to, say, plist which is great for iOS but may not be the best choice for other platforms.
As in most aspects of software development, there is no one-size-fits-all approach to developing a mobile app backend. It all depends on your requirements and constraints. So let's take a moment and make some general assumptions.
- The purpose of the backend is to store data created on the mobile app so that it can be shared across devices and platforms. We want our mobile app to be useful offline, so our app can be used without the API. Unfortunately this means that we'll likely end up duplicating some of the logic across each platform on which this app is developed as well as within the Rails app. Fortunately we should be able to limit this duplication to model validation.
For now on, I will attempt to be consistent with my terminology. When referring to our Rails app, I'll use the term Rails API or just API. To refer to the app running on mobile devices, I'll use the term mobile app or just app.