sajad torkamani

Use Postgres if possible

Heroku has built-in support for Postgres, so consider using Postgres if you have prior experience and it’s a viable option.

Update Gemfile.lock

Assuming you’re deploying your app on Linux, you need to run:

bundle lock --add-platform x86_64-linux --add-platform ruby

Prepare app for production

See this post.

Install Heroku CLI

Create a Heroku account and install the CLI and login. See docs.

Create a Heroku app

  • Navigate to the dashboard.
  • Click on New > Create new app.

Configure deployment method

1. GitHub deployment

(GitHub deployment doesn’t seem to be working at the moment)

  • Go to Deploy > Deployment method and set it to GitHub.
  • Connect to GitHub repo and choose deploy branch. I prefer having a release branch that is always deployed.
  • Enable automatic deploys from your release branch.
  • Add Heroku remote: heroku git:remote -a <app-name-on-heroku>. Adding this remote will help you use the heroku CLI without passing the -a flag each time.

2. Heroku CLI deployment

  • Go to Deploy > Deployment method and set it to Heroku Git.
  • Add Heroku remote: heroku git:remote -a <app-name-on-heroku>

Add master key

If you haven’t already done so, save your master key (config/master.key) somewhere safe (e.g., LassPass vault).

Go to Settings > Config Vars > Reveal Config Vars.

Add a new config var RAILS_MASTER_KEY that’s the value of config/master.key. See this post for more info.

Add environment variables

Add any environment variables that your application relies on.

heroku config:set HOST=<domain> # If your app relies on a `HOST` env variable

Precompile assets

If you’re using the asset pipeline, you’ll want to precompile your assets:

heroku run rake assets:precompile

Enable runtime metadata

heroku labs:enable runtime-dyno-metadata

Dyno metadata will give your dynos easy access to info about the app and the environment. This will help with integrating with tools like Sentry.

Perform a deploy

If you configured GitHub deployment, go to your app’s Deploy page and perform a manual deploy.

If you configured Heroku CLI deployment, commit your changes and run:

 git push heroku master

Perform a migration

heroku run rake db:migrate

Schedule jobs

If you have any jobs that must run periodically, configure them using Heroku Scheduler.

Setup continuous integration


  • Run RSpec tests before deployment is allowed.


View logs

heroku logs -t

Run interactive bash

heroku run bash


Tagged: Rails