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

Written by Habibu | Published 2020/06/21
Tech Story Tags: ruby-on-rails | heroku | backend | live-version | latest-tech-stories | ruby-on-rails-top-story | programming | ruby-on-rails-development

TLDR Getting Your Ruby on rails Application Live On The Internet With Heroku [A How-To Guide] Getting your ruby on rails app live on the internet with Heroku is a guide to deploying it to Heroku. The guide is a step-by-step guide to deploy your app on Heroku and update it every time you make changes to your code. After reading this article your will be able to deploy. your. ruby on. rails app to Herku and push it to GitHub for GitHub users and Heroku users.via the TL;DR App

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'
end
Production group
group :production do
  gem 'pg'
end
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
3. Create a Heroku account on https://signup.heroku.com/
4. Install Heroku CLI. Visit this link to install Heroku CLI https://devcenter.heroku.com/articles/heroku-cli
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.

Written by Habibu | Full-stack software developer. Ruby | Ruby on Rails | Javascript | React | Redux | React-native | Typescript
Published by HackerNoon on 2020/06/21