Deploying your Rails app to Heroku from GitHub

Heroku allows you to have up to 5 projects live on their website for free, and it can run code written in Node, Ruby, PHP, Go, Scala, Python, Java, or Clojure.

Although sometimes it can take a while to load, especially if the app hasn’t been used in some time, it is still a good option for a student that doesn't want to pay to host their side project.

Just be aware that Heroku uses Postgres as its cloud database, so your app needs to be set to use the same.

How to do

Before — After

Once this is saved, push the changes to master.

On Heroku, if you don’t have an account you can signup for free and you will be taken to your dashboard:

On the top right corner click on the button “New” > “Create New App”

Give it a unique name and choose your region, you don’t need to worry about the pipeline, choose the deployment method by GitHub and connect to your account

Once it is done, find the repo of your project and connect, once it is done, you can choose the branch you want to deploy, and it is also a good idea to “Enable Automatic Deploys”, once it is also set, you can “Deploy Branch”.

Once it is finished you will be able to see that it has been deployed, and if it’s a simple app you can “Open App” and see how it looks.

If you are using a database, you will have one extra step, on the top right corner click on “More” > “Run Console”.

This console will work as your computer console, you can even execute commands like Rails C to open the console for your app, or on our case, we will migrate our database, and if you have it, you can also seed it:

The console should say if there was an error when migrating, but if not, you can also check on “More” > “View Logs” to know if there was any issue when running your app.

Now your app is ready to be shared with the world.

Ruby on Rails as an API

This happens, because different form Rails server, Heroku won’t default automatically to the rails welcome page, but if you access the right URL path, you should be able to see your db data.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store