Rails 5 API + ActiveAdmin + Create React App on Heroku
App built following Charlie Gleason's tutorial.
- Create Rails app in API mode
- Make
ApplicationController
inherit fromActionController::Base
- Add
ApiController
(our controllers will inherit from this one) - Add middleware config for
Flash
,Cookies
andCookieStore
toapplication.rb
(see) - Add Devise and ActiveAdmin gems, and install
create-react-app client
- Add config to
package.json
to proxy API calls to Rails backend (see)
- Create Rails models and relationships
- Generate ActiveAdmin resources and permit params
- Set up Rails routes
- Seed database
- Limit retrieved data in controllers (only retrieve what we need for the frontend)
- Add
web:
command to start React (see) - Add
api:
command to start Rails (see) - Run Procfile locally with:
heroku local -f Procfile.dev
- Create Rake task to run Procfile.dev (see)
- Normal React app implementation
- Add
package.json
to the root folder to tell Heroku how to compile React (see) - Use
heroku-postbuild
command to run scripts
- Add
config/secrets.yml
withsecret_key_base
required by Devise - Use Heroku buildpacks to run two build processes in a specific order (Node first)
- Tell Rails to pass any HTML requests that it doesn't catch to React (see)
- Implement React Router