Set up a Rails site on Heroku

The following instructions were written a while back, intended for creating one of my own apps on heroku. Looking for instructions on setting up an app on Heroku for a consulting client? See here.

1) Make sure you have a root page created and routed.

2) Edit config/initializers/devise.rb and uncomment line #11, config.secret_key

3) Install dotenv and create .env (if you haven't already) - Instructions

4) Duplicate config/environments/production.rb and call it staging.rb

5) Commit and push to github

git add .
git commit -m "prepped for heroku"
git push

6) Create 2 the apps in Heroku (using command line)

heroku create appname-staging --remote staging
heroku create appname-production --remote production

(replace appname with the name of my app)

7) Deploy code from GitHub to both Heroku environments (this is the routine for pushing updates)

git push staging main
git push production main

8) Migrate database on both Heroku environments

heroku run rails db:migrate --remote staging
heroku run rails db:migrate --remote production

9) Make the staging Heroku environment the default for all CLI commands (optional but recommended)

git config heroku.remote staging

10) Open Heroku Postgres databases in my Mac app, TablePlus

Open heroku.com > this app > Resources > Under 'Add-ons' click the Postgress Database > Settings > Database Credentials > View Credentials

Last updated