Jungletronics
Published in

Jungletronics

Your First RubyOnRails App On Heroku

How To Install your First RoR App on Heroku — RoRSeries Episode #00

In this post, we will install RubyOnRails App on Heroku using Ubuntu 20.04 LTS and MS WSL 2.

Here is the final result:

Fig 1. My Website running on Heroku host. Just Cool, right? try it: https://jungletronics.herokuapp.com/

Be patient! It takes some time to load…free! Not a problem! Please take a look around the site and its functionalities.

Now, let’s see how to get it yourserf!

00# Step — Install Windows Subsystem for Linux Installation Guide for Windows 10;

Please follow the Microsoft tutorial.

01# Step — Now you can install Windows Terminal:

This tool has become a standard service for users who now access tools such as Command Prompt, Windows Power Shell, and Windows Subsystem for Linux.

How To Install Windows Terminal?

Open the Windows Store and search for “Windows Terminal”:)

Open the Windows Terminal, Click on the drop-down icon (1) and choose Settings (2):

Fig 2. on your terminal, click Settiings to Go To MS Store…
Fig 3. Now choose your distribution…

Please Choose Ubuntu 20.04 LTS at MS Store:

Fig 4. Choose Ubuntu and you are good to go!
Fig 5. All up and running…\o/

02# Step — Install Heroku via your Windows Terminal:

The Heroku Command Line Interface (CLI) makes it easy to create and manage your Heroku apps directly from the terminal. It’s an essential part of using Heroku.

The Heroku CLI requires Git, the popular version control system. If you don’t already have Git installed, complete the following tutorial before installing the CLI:

To quickly setup into /usr/local/lib/heroku or /usr/local/bin/heroku, run this script (script requires sudo and not Windows compatible):

curl https://cli-assets.heroku.com/install-ubuntu.sh | sh

03# Step — Verifying your Heroku installation:

To verify your CLI installation, use the heroku --version command:

$ heroku --versionheroku/7.56.0 linux-x64 node-v12.21.0
Fig 6. Herocu is ok!

Adding keys to Heruku:

heroku keys:add

05# Step — Just create in your home directory a project folder to hold jungletronics app:

cd ~
sudo mkdir project
cd project
sudo mkdir jungletronics
cd jungletronics

06# Step — Create a Repo on Bitbucket:

https://bitbucket.org/gilj3/jungletronics/src/main/

07# Step — Set up the Version Control with Git:

git config — global user.name “jaythree”
git config — global user.email “g***@gmail.com
git config — global push.default matching
git config — global alias.co checkout
git init

08# Step — Key Management and setting Bitbucket as remote:

Set Up Encryption:

ssh-keygen -t rsa -b 4096 -C “g****@gmail.comcat ~/.ssh/id_rsa.pub

Add The Key To Bitbucket:

git remote add origin git@bitbucket.org:gilj3/jungletronics.git

Here is my .git/config file:

j3@JAYTHREE-LAPTOP:~/projects/jungletronics/.git$ cat config[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url =
git@bitbucket.org:gilj3/jungletronics.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "heroku"]
url =
https://git.heroku.com/jungletronics.git
fetch = +refs/heads/*:refs/remotes/heroku/*

09# Step — Adding keys to Heruku

heroku keys:add

10# Step — Save your first code:

git add .
git pull
git commit -am 'initial commit'
git push -u origin master — force

11# Step — Getting started with Heroku:

After you install the CLI, run the heroku login command. You’ll be prompted to enter any key to go to your web browser to complete login. The CLI will then log you in automatically.

$ heroku login
heroku: Press any key to open up the browser to login or q to exit
› Warning: If browser does not open, visit
› https://cli-auth.heroku.com/auth/browser/***
heroku: Waiting for login...
Logging in... done
Logged in as me@example.com
This page will open, enter your heroku recovery code, and voila!!! Close this page and …
You are ready to go!

If you’d prefer to stay in the CLI to enter your credentials, you may run heroku login -i

$ heroku login -i
heroku: Enter your login credentials
Email: me@example.com
Password: ***************
Two-factor code: ********
Logged in as me@heroku.com

The CLI saves your email address and an API token to ~/.netrc for future use. For more information, see Heroku CLI Authentication.

heroku — version (heroku/7.56.0 linux-x64 node-v12.21.0)
heroku login
heroku keys:add
heroku create

12# Step — Now you’re ready to create your first Heroku app:

$ cd ~/myapp
$ heroku create jungletronics
Creating example... done
https://jungletronics.herokuapp.com/ | https://git.heroku.com/jungletronics.git
heroku git:remote -a jungletronics
set git remote heroku to https://git.heroku.com/jungletronics.git

13# Step — Running Ruby Alex Ishida Installation Scrippt:

https://gist.github.com/alexishida/655fb139c759393ae5fe47dacd163f99

This script will install rbenv, Ruby, nodejs and yarn in your Ubuntu 20 Distribution :)

To finish the inslallation, please run these commands:

rbenv-ruby-rails-install.sh
chmod +x rbenv-ruby-rails-install.sh
sudo ./rbenv-ruby-rails-install.sh

The application is now deployed. Ensure that at least one instance of the app is running:

heroku ps:scale web=1Scaling dynos… done, now running web at 1:Free

Now visit the app at the URL generated by its app name. As a handy shortcut, you can open the website as follows:

heroku open ▸ Error opening web browser.
▸ Error: Exited with code 3

▸ Manually visit
https://jungletronics.herokuapp.com/ in your browser.

14# Step —Now its time to Learn Ruby On Rails — Prepare the app:

In this step, you will prepare a simple application that can be deployed.

To clone the sample application so that you have a local version of the code that you can then deploy to Heroku, execute the following commands in your local command shell or terminal:

git clone https://github.com/heroku/jruby-getting-started.git
cd jruby-getting-started

You now have a functioning Git repository that contains a simple application as well as a Gemfile file, which is used by Ruby’s dependency manager, Bundler.

heroku git:remote -a jungletronics

15# Step — Commands examples:

615  git push heroku master
1616 heroku git:remote -a jungletronics
1617 git push heroku master
1618 git push heroku master --force
1619 git push heroku main
1620 git add .
1621 git commit -am 'including j3 logo'
1622 git push
1623 git push heroku main
1624 git add .
1625 git commit -am 'fixing j3 logo'
1626 git push
1627 git push heroku main
1628 git add .
1629 git commit -am 'links to jungle & kidstronics '
1630 git push
1631 git push heroku main
1632 git add .
1633 git commit -am 'links to udemy course '
1634 git push
1635 git push heroku main
1636 git add .\
1637 git add .

That’s it!

Now, we have heroku toolchain running inside your ubuntu wsl!

visit: https://jungletronics.herokuapp.com/

visit: https://bitbucket.org/gilj3/jungletronics/src/main/ to understand RoR app :)

That’s all for today!

I hope you enjoyed that lecture.

If you find this post helpful, please click the applause button and subscribe to the page for more articles like this one.

See you soon!

--

--

--

J of Jungle + 3 Plats Arduino/RPi/Pic = J3

Recommended from Medium

Best APIs To Get Real-Time Forex Rates

Part 4: Example and Benefits of adopting the ADR process

Build your first Helm chart with Docker Desktop on Mac

Use These Web Scraping Tools To Extract Data From Websites

Learn While You Sleep With This Audio Converter API

Back to Basics: HTML, CSS, and JavaScript Refresh

Database for Flutter Application

How to use the Amazon Product API in Ruby

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
J3

J3

Hi, Guys o/ I am J3! I am just a hobby-dev, playing around with Python, Django, Lego, Arduino, Raspy, PIC, AI… Welcome! Join us!

More from Medium

A Django Blog In VS Code — Self-Service Django Password Reset

A Simple CRUD Application with Django

Install NodeJS on Windows

screen capture of nodejs installer and docs

Hashing vs Encryption In Less Than 5 Minutes