Getting Your Ruby on Rails Application Live On The Internet With Heroku [A How-To Guide] | Hacker Noon

June 21st 2020

Author profile picture

As a back-end developer, the happy moment is to show your client that the work is now is live on the internet, everyone on the world can access the website. In this article, I will share my experience step by step to deploy your ruby on rails application on Heroku.

After reading this article your will be able to deploy your ruby on rails app to Heroku and make an update every time you make changes to your code.

 Here are the steps.

1. Create your app initially with the PostgreSQL as the default database, this will make the work simple because rails use sqlite3 as default database so you need to make changes in the gem file. Where sqlite3 is placed inside the group development and PostgreSQL is placed inside group production.

Development group

group :development, :test do
   gem 'sqlite3'

Production group

group :production do
  gem 'pg'

After that run bundle install.

Alternatively, the simple way is to create your app initially with PostgreSQL as the default database.

rails new wordapp -d postgresql

easy and no need to touch the gem file.

2. Create the GitHub repository and push your app to GitHub for GitHub users.

git init
git add .
git commit -m"final commit of ready project"
git push origin master

5. Login to Heroku, type the command below it will ask your email and password.

heroku login -i

6.Create the app on Heroku using the below command.

    heroku create name-of-the-app

7. Push your code to Heroku use master branch.

git push heroku master

8. Migrate the Heroku database.

heroku run rake db:migrate

9. Heroku open.

heroku open

this will redirect to your app web page or it will give the URL copy it and paste to the address bar, your good to go.

10. Now your app is live on Heroku , every time you make changes to your code you will be updating by pushing to GitHub and Heroku by repeating the command in step no 8.

For any feedback don’t hesitate to contact me.

Thank you for reading.


The Noonification banner

Subscribe to get your daily round-up of top tech stories!

read original article here