Rails Girls - Pushing to Heroku on Cloud 9
Created by Sorcha Abel, @sabel25
Getting started
Deploying to Heroku on Cloud 9 is easy! All you need is a Heroku Account. If you don’t already have you sign up here -> sign up page Then all you need is to remember your username and password :)
Updating our database
Return to Cloud9 and open the Gemfile We need to make a small change in order to get our database to work on Heroku. It uses a database called PostgreSQL which is more suited to a production environment than SQLite which is the database we have been using so far. Please change the following in the Gemfile:
to
Here we are telling our app that when in production environment use PostgreSQL (that’s the pg bit) and when in a development environment use the SQLite database. Clever huh!
Finally save the Gemfile and run bundle install --without production
to setup your dependencies.
Commit your changes to github
Deploying your app
App creation
You first need to login to Heroku, type heroku login
and enter your heroku username and password
To ensure we are using the most up to date version of Heroku enter the following command in the terminal window of Cloud 9
wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
Next we need to create our Heroku app by typing heroku create
in the cloud 9 terminal and see something like this:
In this case “murmuring-bayou-70721” is your app name.
Pushing the code
Next we need to push our code to heroku by typing git push heroku master
. You’ll see push output like the following:
You’ll know the app is done being pushed, when you see the “Launching…” text like above.
Migrate database
Next we need to migrate our database like we did locally during the workshop: heroku run rake db:migrate
.
When that command is finished being run, you can hit the app based on the url. For this example app, you can go to http://sheltered-refuge-6377.herokuapp.com/. You can also type heroku open
in the terminal to visit the page.
Keep in touch
Follow us on twitter
Sorcha Follow @sabel25
Rachelle Follow @RachelleOnRails
Rails Girls Brisbane Follow @railsgirlsbne
Read the Rails Girls Brisbane blog http://railsgirlsbne.com/
Email us: Rails Girls Brisbane
Join our Facebook Group: Rails Girls BNE Group