Ruby on Rails – deploying to Heroku

To deploy to Heroku, follow these steps:

  1. Open the Gemfile in your app.  Heroku doesn’t support sqlite3 (they support postgresql) so we have to change that.  Remove gem 'sqlite3' and put it near the bottom under group :development do
  2. At the very bottom of Gemfile, type
    group :production do
    gem 'pg'
This lets us use postgresql while developing but sqlite3 when we actually produce.

To get this to actually take effect, we need to commit to our repository.  We do this by typing this in shell: bundle install --without production.  Then log in to and find instructions for installing heroku toolbelt on local machine.  The course wasn’t clear about how to install locally, but I think this code should do it. curl | sh. I think the piece we are trying to install is called CLI (used to be called Toolbelt?). Type heroku -v to make sure heroku was installed correctly.

Now log in to heroku using heroku login. You’ll be redirected to a browser to login. We need to create an application in heroku for our application. To do that, use heroku create. If you then use git status you’ll see what hasn’t been committed and what has. Remember to use git add -a and git commit -m "whatever you want the message to be" to add the changed files to your commit.

Lastly, we need to add our ssh key to heroku.  If I don’t, it will continually ask me for my username and password.  Just use the codeheroku keys:add.   Once this is done, you should be able to push your application to heroku. When I tried to push the application to heroku, I ran into an issue because bundler had been upgraded to bundler 2.  I first had to run this command:  heroku buildpacks:set but then after that, I was able to git push heroku master to send the app to heroku.

That is completed and here is the site. To rename the site, use the code: heroku rename new-name-of-site (whatever you want it to be).