Publishing a Rails 4 App on Heroku using Git

Publishing a Rails 4 App on Heroku using Git

Last updated:

The following guide is best suited to debian-based (e.g. Ubuntu) Linux boxes

Well, first of all you need to place your app in a git repository - if it isn't already.

  • Install Heroku Toolbelt

A set of command-line utilities to help you manage your Heroku apps.

    $ wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
  • Create your Heroku app

This will tell git that you're going to link this project with a remote app on Heroku, (create git remotes for you to push your code to):

`cd`to your project directory and run:

    $ heroku create

(You'll probably be prompted for your Heroku username;e-mail and password) - Creating a Database (postgresql)

    $ heroku addons:add heroku-postgresql:dev
  • Establishing your database

Replace RED with your database color.

    $ heroku pg:promote HEROKU_POSTGRESQL_RED_URL

You can find out your database name and color via:

    $ heroku config | grep HEROKU_POSTGRESQL
  • Push your code

    $ git push heroku master
    
  • Migrate your database

This took me a little while to figure out because I was under the impression that one needs to run db:create prior to running db:migrate (like on local apps) but apparently you only need to migrate.

    $ heroku run rake db:migrate

Other useful stuff:

Reset your database on Heroku

Replace PINK with your database color:

$ heroku pg:reset HEROKU_POSTGRESQL_PINK_URL

Push your app to Heroku

$ git push heroku master

Create a Public-key

You probably need to create a public-key on your machine and paste it onto you Heroku profile page. For more info, see this post on creating key pairs on ubuntu.