Home » Ruby Tutorial Box » Pushing a Rails app to Heroku

Pushing a Rails app to Heroku

heroku-Logo-1We will be creating a very simple blog using Rails 4, RSpec then deploy it to Heroku today, mainly focus on the way to implement TDD. The blog will use postgresql to be able to push to Heroku. We’re going to get rid of some defaults on generating the application.


Let’s generate the bare app first:

what we have now is a skeleton without test directory (as we plan to use RSpec instead), configured to use postgresql (config/database.yml, pg gem automatically added to Gemfile) and bundle install didn’t run yet.

Then go add these gems to the Gemfile:

Now  run bundle install and install RSpec: rails g rspec:install. It will generate the spec directory.


Let’s start with spec by writing a feature spec using RSpec and Capybara.

Remember to fill the postgresql credentials in config/database.yml and run these commands to prepare for test database:

Run rspec spec to see it goes red.

Ahhhh, we don’t have the root path yet, let’s go define it in config/routes.rb then run spec again

Ahhhh,  we don’t have the Pages controller. go to app/controllers and add a pages_controller.rb file with this content and run spec again

Ahhhh, now it couldn’t find the home action, let’s add it to the class body

Ahhhh, now it’s looking for the view template, let’s go add a template in app/views/pages/home.html.erb and run spec again.

It now looks for the welcome text and the link, let’s add them to the template

So on, gradually we implement minimum code to pass the specs….


After we finish the blog, let’s initialize a git repo and commit.


We now have an application running on our local computer. Let’s deploy it to Heroku for the whole world to know who we are :))

First we need to install the Heroku toolbelt, download and install it here: https://toolbelt.heroku.com/

After installing heroku toolbelt, the heroku command will be available. We need to login, create and push the application
to Heroku. Be sure you have a Heroku account first (register one here if you haven”t http://heroku.com)

The blog is now available at http://septeni-blog.herokuapp.com/.