It doesn’t matter if you’re a full-time developer, student or just someone who wrote their first “Hello World” app, we all have something in common. At one point “localhost” won’t be enough and we want to deploy our site so everyone can see it. In this tutorial I’ll show you how easy it is to deploy your “Hello World” app on Heroku.

You’ll need the Heroku CLI which will allow us to do everything from the terminal. If you don’t have it installed, follow the instructions here: https://devcenter.heroku.com/articles/heroku-cli
I’m using Ruby `2.5.3` and Rails `5.2.3` for this tutorial. Let’s get started by creating our Rails app in the terminal by executing this command:
rails new medium-demo --database=postgresql
It’s important to define which database we use when it comes to Heroku and the most common choice is PostgreSQL. It‘s not recommended to use SQLite with Heroku because our apps rollback our uploaded files every 24 hours. You can read more here about it: https://devcenter.heroku.com/articles/sqlite3
Once that’s done we can create our basic controller, define the root route and create a basic welcome message that the user will see.
To generate our controller:
rails g controller home
In our config/routes.rb file:
root 'home#index'
In app/controllers/home_controller.rb
def index; end
And finally create a .erb file inside our app/views/home folder, called index.html.erb and write this inside:
<h1>Hello World</h1>
Once that’s done, let’s get back to the terminal and create our Heroku app and attach a database to it. Let’s start with logging in to Heroku by typing:
heroku login
Once we’ve done this, create the Heroku app in the terminal. You can define a custom name for your app, or you can let Heroku assign a randomly generated name for your app. Just simply type:
heroku create
Heroku also allows you to extend your apps with “add-ons”. You can find almost anything in the marketplace that you can use for free or for a small fee. For now we will use a free hobby-tier PostgreSQL database. It is important to mention that the free tier products are not meant for production environments.
heroku addons:create heroku-postgresql:hobby-dev
Now we have our database and app set up, let’s start to deploy. First, we will need a so called `Procfile` that Heroku will use to set up the environment for our app. It has to be called exactly like this, without any file extension. Let’s create our Procfile and insert this snippet into it:
touch Proc
filenano Procfile
and finally paste this inside the file and save it:
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
You should be inside your rails app at this point, and if you type `git remote -v` you should see that your app is a repository that links to Heroku. The only thing we have left to do is just to commit and push the changes to the repository.
git add .git commit -m"init"git push heroku master
After the push you will see that Heroku starts to build your app on the remote server and give you constant feedback from every stage. You will see it installing your gems, checking your Procfile and everything else. It might take some time, around 2–3 minutes.
One last thing left to do - we have to run the migrations, so just type this in the terminal and after that you are all set!
heroku run rake db:migrate
After you’ve done this, just go to your url and you can see that your “Hello World” is now readable for everyone.