• Complain

Jessie Young - iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends

Here you can read online Jessie Young - iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2014, publisher: thoughtbot, genre: Home and family. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Jessie Young iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends
  • Book:
    iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends
  • Author:
  • Publisher:
    thoughtbot
  • Genre:
  • Year:
    2014
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Jessie Young: author's other books


Who wrote iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends? Find out the surname, the name of the author of the book and a list of all author's works by series.

iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
iOS on Rails (Beta)
iOS on Rails Beta thoughtbot Jessie Young Diana Zmuda iOS on Rails Beta - photo 1
iOS on Rails (Beta)
thoughtbot
Jessie Young
Diana Zmuda
iOS on Rails (Beta)
Introduction
Why this book?

There are many ways to build the backend for an iOS application but you only need one. And depending on the complexity of the API you are going to create, different solutions work best for different applications.

Just as Rails makes it possible to set up a basic web application in a matter of minutes, Rails makes it possible to set up a basic API in a matter of minutes. But deciding how to structure your API isn't easy. While experimenting with all of the options is a fun weekend project, sometimes you just want to get going. This book will help you do just that. While your API will no doubt require some tweaking while fleshing out your iOS app, the approach we will be taking is to define and build the API first, and then consume this API through our iOS app.

The Rails portions of iOS on Rails will guide you through what we have found to be a robust, clean, flexible way of building out a JSON API with Rails. We provide code samples for GET, POST, and PATCH requests. In addition, we will explore some of the alternative approaches that we didn't choose and explain why we made the choices that we did.

The iOS portion of the book will then walk, step-by-step, through creating an iOS application that works with the Rails API you just created. The iOS application will use each endpoint to post up objects and get back necessary data for the user. Our model objects in the iOS app will correspond with the model objects in the database, and be populated with response data from the API.

Who is this book for?

This book is for a developer who wants to build an iOS application with a Rails backend. It's also a book for both a Rails developer and an iOS developer to share and use in concert to create an app quickly and with more flexibility to change it than a backend-as-a-service provider like StackMob or Parse.

The approach shared in this book is the result of our own experiments as Rails and iOS developers working together to build an application. The Rails portions of this book assume a basic working knowledge of how to build a web application with Rails as well as the Ruby programming language. The iOS portions of this book assume experience with object oriented programming and a basic familiarity with the Objective-C programming language.

This book is intended to be used as a guide rather than a recipe. While our aim is to give you all of the tools necessary to build great Rails APIs and iOS clients, it does not cover the fundamentals of Ruby, Rails or Objective-C. That being said, if any part of the book strikes you as incomplete or confusing, we are always happy to receive pull requests and issue submissions on GitHub.

Introduction to our example application and setup
Example application

We will use a fake example application called Humon to explain and demonstrate the concepts throughout this book. Humon is an app that lets you find nearby events.

In the Humon application, a user can have many events as an event owner. An event has geolocation information (latitude and longitude), which allows us to plot it on a map. A user has and belongs to many events through attendances. A user can only have one attendance per event.

Humon database representation The Humon application does not ask for a username - photo 2

Humon database representation

The Humon application does not ask for a username or password. Instead, we will use an ID unique to the device ('device token') to track unique users. The iOS portion of the book will discuss where this token comes from. For now, all you need to know is that users are identified by their devices. This approach does not allow for multiple users per device or a single account across devices, but it does enable users to start using the application immediately. Our desire to create the simplest application possible led us to choose immediate usability over a more complex authentication system.

We will provide code snippets in context, but you can also view the entire example application in GitHub to see how it is structured.

Setting up our project

We used Suspenders, a Rails 4 template with thoughtbot's standard defaults, to start our project. Starting a Rails app with Suspenders is simple, just follow the instructions in the README.

While Suspenders is not required to follow along with this book, it does conveniently include all of the gems we will use to test-drive our API, including: Factory Girl, RSpec, and Shoulda Matchers. So if you choose not to use Suspenders to start your project, make sure you add those gems to your Gemfile.

Parsing incoming JSON requests

MultiJson is an adapter for JSON parsers. Another adapter familiar to Rails developers is ActiveRecord. Just as ActiveRecord provides a common interface to database drivers like Postgres and MySQL, MultiJson provides a common interface to JSON parsers like Oj and Yajl. We get MultiJson for free with Rails because MultiJson is a dependency of ActiveSupport.

For parsing JSON, we chose the Oj gem. To use the Oj gem in your Rails application, simply add it to your Gemfile and install it with the bundle install command. We chose Oj because it is a really fast JSON parser. From the MultiJson README:

"When loading, libraries are ordered by speed. First Oj, then Yajl, then the JSON gem, then JSON pure. If no other JSON library is available, MultiJSON falls back to OkJson, a simple, vendorable JSON parser."

Generating outgoing JSON responses

There is no shortage of methods to render a JSON response. We looked into Active Model Serializers, RABL, and simply using the Rails .as_json method. In the end we chose Jbuilder for rendering JSON because of its excellent community support (repo is maintained under the Rails organization) and the consistency of its view logic to other kinds of Rails views such as Haml, ERB, and Builder.

With Jbuilder, we render the JSON from Rails controllers like any other view. We're able to use partials like any other Rails view template to compose JSON. There's also a cache! method that has the same method signature as ActionView::Helpers::CacheHelper and uses Rails.cache under the hood. We will delve into the details of views and caching in later chapters.

Versioning

Before we get started with building out our API, we must think about how we are going to handle versioning. While web developers can deploy as often as they want and users see the newly deployed code with every browser page refresh, iOS developers have both a lag time before Apple approves the new version of an app and a lag time before users update to the newest application version available. iOS applications reference the same API endpoints until a new release of the application has been downloaded. If you want to continue to support users with older versions of the iOS application you are building, you must maintain the same general JSON data structures on the backend for those users.

You will of course discover new and better ways of structuring your JSON responses as time goes on and your application grows. Once that happens, the easiest way to support old versions of the application and allow newer versions to use different JSON structures is to release a new API version.

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends»

Look at similar books to iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends»

Discussion, reviews of the book iOS on Rails. The reference for writing superb iOS apps with Ruby on Rails backends and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.