Skip to content

Instantly share code, notes, and snippets.

@omgreenfield
Last active September 3, 2016 09:41
Show Gist options
  • Save omgreenfield/571b3beaee7e4acaca9ff0d77320e73b to your computer and use it in GitHub Desktop.
Save omgreenfield/571b3beaee7e4acaca9ff0d77320e73b to your computer and use it in GitHub Desktop.
How to Make a RoR App Ready for Heroku Deployment

When you make a new Ruby on Rails app, there are a few changes you must make to your app so that the production environment (Heroku) functions properly.

Firstly, if you don't have the Heroku CLI installed and the app setup. Go do that. This page isn't for that.

Next, in your Gemfile, make sure that if you're using anything other than postgreSQL for your Dev DB, you isolate it. Heroku uses postgreSQL.

Heroku also uses some other gem that the dev environment doesn't need. So you should have different gems for dev and production. Like so:

group :development, :test do
  gem 'sqlite3' # SQLite3 gem for dev and test environments
end

group :production do
  gem 'pg' # the postgreSQL gem
  gem 'rails_12factor' # that special gem that Heroku needs
end

Make sure to bundle install after making that change.

You'll also need to update your database.yml file so it reflects the change in DB adapter. Here's a template you can use:

default: &default
  pool: 5
  timeout: 5000

development:
  <<: *default
  adapter: sqlite3
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  adapter: postgresql
  encoding: unicode

If things still aren't working, check out the Heroku Rails document here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment