Set up a working environment for Ruby on Rails Programming

lionnelpat

Lionnel Patrick

Posted on July 4, 2020

Set up a working environment for Ruby on Rails Programming

Hello, we continue with our series Discovering Ruby on Rails. In previous articles, we have presented some basic concepts of the web. Today we are going to show you how to install the ruby ​​programming language on your computer.

While you are on a Mac, Windows, or Linux, we will show you the different steps to install Ruby. For my part, I advise you to work on Linux or Mac OS. Indeed, with Windows, everything will be fine but sometimes further in your projects, you may encounter some small difficulties. You are ready, so let's go!
You can use different tools to install Ruby.

If you are on a UNIX-like operating system, using the package manager on your system is the easiest way to do this. However, the latest version of Ruby may not be available.
An Installer can be used to install one or more versions of Ruby. There is also an installer for Windows.
Managers help you switch from one version of Ruby to another on your system.
And finally, you can also compile Ruby from source.

The following summary lists the installation methods available for different needs and platforms.

Windows Installation

the safest and fastest way to install Ruby on Windows is to use the RubyInstaller utility. It provides you with everything you need to set up a complete Ruby development environment on Windows.

Download it, launch it, next, next, next…. and that's it!

Just a little clarification! Note that the list of options has sections "with Dev Kit" and "without Devkit". Dev Kit versions install the MSYS2 system, which will be required if you need to install RubyGems that require compilation. Since we will be working with Ruby on Rails later, I advise you to use the "with Devkit" option

You can also use Bitnami Ruby Stack, which provides a complete development environment for Rails. It is available for macOS, Linux, Windows, virtual machines, and images for the cloud.

Mac OS installation

In Call World, things are a little bit different ... then you will need an internet connection, administrator rights and also a little time ...
For my part, I do not have a Mac and I do not have enough experience on this system to drive you. I will, therefore, give you a list of reliable resources by which you can install Ruby ​​on Mac OS.

stackify
gorails

By the way, if you want to pay me a mac, don't be shy…. it will make me really happy

Linux Installation

I work on a Linux Ubuntu 18.04 system. In this part we will make all the necessary installations in order to have an adequate working environment.

1-Installation and configuration of git

  • sudo apt install git
  • git config --global color.ui true
  • git config --global user.name "YOUR NAME"
  • git config --global user.email "YOUR@EMAIL.com"
  • ssh-keygen -t rsa -b 4096 -C "YOUR@EMAIL.com"0

The next step is to take the newly generated SSH key and add it to your Github account.
ssh -T git@github.com

You should receive a message like this: Hi excid3! You have successfully authenticated, but GitHub does not provide shell access.

2-install an Editor or IDE

To write the code, we will need a third-party application. There are three types:

  • text editors. Ex :, VSCode, Atom, SublimeText,
  • IDE: Rubymine,
  • command line applications Ex: Vim

Be free to install the tool you are most comfortable with.

3-install node js

  • sudo apt install curl
  • curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash
  • sudo apt install nodejs
  • node --version
  • npm --version

4-Install Yarn

The stages of the process were inspired by the work of this site.

  • curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add
  • echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  • sudo apt update
  • sudo apt install yarn
  • sudo apt install --no-install-recommends yarn → to install NodeJs
  • yarn --version

5- Install ruby

The stages of the process were inspired by the work of this site. There are several ways to install Ruby.

Option 1: Install Ruby from the Ubuntu Repository

  • sudo apt update → to update packages
  • sudo apt install ruby-full → to Start the Ruby installation process
  • ruby –v → to verify version

Option 2: Installing Ruby with RVM

Step 1: Install GPG

sudo apt install gnupg
gpg --keyserver hkp: //pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB → to install keys

Step 2: Install RVM

  • sudo apt install software-properties-common
  • sudo apt-add-repository -y ppa: rael-gc / rvm
  • sudo apt update
  • sudo apt install rvm
  • Restart your system

Step 3: Install Ruby

rvm install 2.6.5
ruby –v

6-install Postgres

The stages of the process were inspired by the work of this site.

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/` lsb_release -cs`-pgdg main ">> /etc/apt/sources.list.d/pgdg.list'

→ to install keys
sudo apt update
sudo apt -y install postgresql postgresql-contrib

After installation, log in to the default user called "postgres" and run the PostgreSQL command line interface "psql".
su - postgres psql

Now add a new password for the Postgres user by running the following query on the psql interface.

\ password postgres

Type your password

7-Install postgresAdmin4

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/` lsb_release -cs`-pgdg main ">> /etc/apt/sources.list.d/pgdg.list'

sudo apt update
sudo apt install pgadmin4 pgadmin4-apache2 -y

  • Type your own email address which will be used as the username.
  • Enter your password once the installation is finished, run pgadmin4 on your terminal to start your server.

8- Install rails v 6.0.3

gem install rails -v 6.0.1
rbenv rehash (only if you’re using rbenv
rails -v (to verfy)

Ruby on Rails welcome Page

If you have successfully installed all of these different tools, then we can move on. In the next chapters, we will see in more detail what the Ruby language is, the data structures, the functions, the loops, the syntax, the classes, objects ... So see you next week ...

💖 💪 🙅 🚩
lionnelpat
Lionnel Patrick

Posted on July 4, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related