Deploy Your First Rails App With Heroku

If you are starting to learn this beautiful framework, you will be interested in taking your first project, demo or task to production, which is what really matters when developing. Also, you can do it for free!

Heroku helps you forget about the infrastructure aspect that exists behind as well as the security aspects and also manages all this for you in the cloud. In other words, you only worry about your application working and having your Config Vars set correctly.

Make sure you have this ready before you start:

If you want to start without any previous repository, you can download one from here or just clone it from the terminal:

$ git clone

We’ll use Heroku CLI in order to streamline our process. For static pages, you just need to follow this few steps:

  1. Login

At this step, you will be redirect to a login page from Heroku. All you need to do is to push your credentials as usual.

$ heroku login

2. Create App

Add a name to your App so that you will recognize it when it is published on the Internet. Make you are stand on the root of your project.

$ heroku create my_test_app_name

If you regretted about the name you gave to your App, don’t worry, use this command as many times as you like:

$ heroku apps:rename another_name_for_my_app

3. Push on Heroku

In this case we are deploying the ‘‘main’’ branch of our project. But in your case, you can decide what other branch you want to deploy, just replacing it.

$ git push heroku main

4. Open your website

Running this command, automatically will open your deployed project on the browser.

$ heroku open

You finished! But, maybe you want to use any database to use CRUD (Create, Read, Update and Delete) operations in your App. In this case, you need to know that Heroku no longer supports “SQLite” as a production database, which is the default database for Rails.

A way to solve this is to add a production environment configuration in your Gemfile, like this:

Setup Environment Configuration for Rails

In my case, I added PostgreSQL gem for my production database and keep the default database for the development environment. Then, run bundler without consider your production environment:

$ bundle --without production

Almost you finished, just need to update your code on your remote repository and then run the database migrations for the production environment:

$ heroku run rake db:migrate

You are done! Now, open again your browser to see changes.

As final words, I suggest to you to keep learning Rails if you are starting on this. You will really notice the time you save building websites in comparison with another technologies available on the market.

Developer seeking problems to solve.