Deploy Your Rails App to Heroku

Carly Ann Pecora
May 28, 2019 · 2 min read

Congrats on finishing your Rails Application! You’re ready to deploy!

Heroku is a great service that enables anyone to deploy his or her app. You can download and install heroku here; or using Homebrew you can type into your terminal:

$ brew tap heroku/brew && brew install heroku

You must create an account, and you can do so here. Login through the command line using:

$ heroku loginheroku: Press any key to open up the browser to login or q to exit:

Press any key to be redirected to login page; once logged in, you will have access to Heroku Command Line.

From here, cd into your app’s directory and find your Gemfile. Find your SQLite3 gem:

gem 'sqlite3'

and change to Postgres:

gem 'pg'

and run bundle install from your command line. PostgreSQL is a much more advanced database and works better with heroku. You can find instructions to install Postgres here. Ensure that Postgres is running, and change your config/database.yml from this:

to this:

Note: the name of the app I am deploying is Dancer-Shoes. Replace this with your app’s name.

If you are having trouble converting your database from SQLite to Postgres, check out this awesome post.

Run $ rake db:create followed by $ rake db:migrate and $ rake db:seed (if you have a seed file) to set up your Postgres database. If it worked, you’ll see your database running in Postgres:

If your app is connected to Github or stored in git, you’re ready to deploy! If not, run the following in your terminal:

$ git init
$ git add .
$ git commit -m "init"

If you run $ git status and receiveOn branch master
nothing to commit, working tree clean
as a response, you’re ready to go!

Run:

$ heroku create

and

$ git push heroku master

and

$ heroku run rake db:migrate to use your application’s database.

And boom! You’ve done it!

These last two steps may take some time.

To open your newly-created app, run $ heroku open .


More From Medium

More from Carly Ann Pecora

More from Carly Ann Pecora

Routing Your React App

More from Carly Ann Pecora

More from Carly Ann Pecora

Ruby Return Values

Top on Medium

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade