Incremental Rails to SPA Migration with Mock APIs

Table of Contents

1. Background

Provide a simple mechanism from creating a base Rails application with an incremental path to migrate to a SPA backing based on a namespace switch to /api.

The goal will be to keep all of the core business logic for persisting data in Rails but gradually move features to the front-end in either Angular or React.

2. Scenario

2.1. Create a mock Rails application

rails new appmigapi

2.4. Create initial consumer of mock API

yeoman new react-app

2.5. Return JSON rather than HTML

respond_to :json

2.6. Load mock data

group :development, :test do
  gem 'faker'
end

3. Links

4. Tools

4.1. Swagger