Getting up & running with Heroku for Rails – Part 1

January 7, 2016 - 4 minutes read

So all the bugs have been washed up, and your project is working successfully on your local machine, so it is the time to go for deployment. If you are a kind of a person who wouldn’t like to go through all the hurdles of installing Git, Ruby and all the dependencies of Rails including the database, well – you are fortunate because Heroku has solved all the problems for you or it has at least made it real easy to install the dependencies and deploy your application in a matter of few commands.

Heroku is PaaS: platform as a service where you are supposed to upload your project, and Heroku is going to take care of most of the tasks for you. Unlike AWS or Amazon Web Services which is IaaS: infrastructure as a service, and you are supposed to install and configure all the necessary components if you successfully want to install a project, Heroku is a lot easy to configure and use. In this article, we shall see how we can deploy a Rails application successfully to Heroku platform.

The very first thing that you need to do to get started with deployment is signing up on Heroku, and it is free.

Follow this link to get started with Heroku sign up process, and don’t forget to choose Ruby as your development language in this process.

Once you are done with it, the next thing you got to have installed is Heroku Toolbelt. Heroku Toolbelt is basically a command line interface that you can use to create and manage Heroku apps. You can head over to this link to get it installed.

Now that you have installed the necessary components, it is finally the time to see some action of powerful Heroku commands.

First off, you need to log in through Heroku Toolbelt to authenticate yourself, and you can do so by invoking the following command:

It will ask you enter your email and password, and if you did everything correctly, it was present the message Authentication successful at the end.

Now, you need to enter into the directory of the project that you would like to deploy to Heroku, let’scallit users_api.

In response of invoking heroku create , you are gonna see the following output on your terminal screen:

It will create a new application of some random name that will be deployed on Heroku. You can configure the name of the application later on.

The most important thing that it will do is: it will add heroku to the remotes of Git as you can see in the screenshot where it says Git remote heroku added. You can further verify this thing by invoking the following command:

Screen Shot 2016-01-07 at 6.25.33 PM

Well, that specifies the thing that you need to push your changes to heroku remote if you want to see your changes in the current directory deployed to Heroku.

At this point, you should note one thing that Heroku supports only Postgresql (as of writing this article) among other databases, so if your application is using MySQL or MongoDB, you need to switch the settings to Postgresql before you deploy your app to Heroku.

Not only this, we also need to configure a few other things before we get ready to send the changes to Heroku for deployment. So follow us for the next article where shall we configure the project, and finally be able to see it live on Heroku. Happy deploying!

Tags: ,