Step-by-Step Guide to Ruby on Rails Installation and Setup

January 30th, 2024
10086
Ruby on Rails Installation

Ruby on Rails, also commonly just called Rails, is an open-source software that is written in the Ruby language. This server-side, free web app development framework, curated with the purpose of making the process of programming web apps easier. Rails is an MVC or model-view-controller framework. This means it facilitates the programmer to accomplish more with less code. It has gained a lot of popularity in recent years, and continues to be a favorite among developers. In this blog, we are going to give you a step-by-step guide to Ruby on Rails installation and setup.

Learn Rails with igmGuru's advanced Ruby on Rails training program.

Install Rails on Windows

To install Rails on Windows, these steps must be followed.

Step 1: Check the Ruby Version

The first thing to do during Ruby on Rails installation is to check whether you have Ruby already installed. To do this, open the ‘command' prompt, and type ‘ruby -v'. Upon responding, if the version number is at or above 2.2.2, type ‘gem --version'.

If you do not get an error, skip the next step. Otherwise, you will have to install Ruby on Windows.

Step 2: Install Ruby on Windows

If Ruby is not already installed, then you can do so by downloading the installation package by going to rubyinstaller.org.

Click on the ‘download' link and then run the resulting installer. It's a small package, gets installed in one click, and you get RubyGems along with it.

Ruby on Rails Installation

Step 3: Install Rails

Now that you have RubyGems, installing Rails and its dependencies can be done with a single command line-

C:\> gem install rails
Install Ruby on Rails

NOTE: It might take a little while to install all the dependencies. Hence, be certain to stay connected to the internet.

Step 4: Check Rails Version

To check the Rails version, use this command.

C:\> rails -v

The output you will get -

Rails 4.2.4

And voila! Your Ruby on Rails download is complete and you can enjoy Ruby on Rails Windows.

You may also read- How To Become Ruby On Rails Developer?

How to Install Ruby Ubuntu?

To install Ruby Ubuntu, there are a few ways you can follow. In this blog, we will be using Rbenv for installing Rails in Ubuntu. Another tool named ruby-build is needed to install Ruby.

Before we move to the steps, let's make an important pitstop.

Prerequisites for Ruby on Rails Installation on Ubuntu

Before we move on to the steps that you must undertake for Ruby on Rails installation, here are the two key installations you must have-

  • Apache (or any preferred web server of your choice)
  • A database service (like MySQL)

To update Ubuntu 20.04, use-

sudo apt update

To install Ruby dependency packages, use this command-

sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev

Once the installation of dependency packages is complete, use this command to clone both Ruby-build and Rbenv repositories at GitHub.

curl -sL curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash

Run this command to set path in .bashrc-

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrcecho 'eval "$(rbenv init -)"' >> ~/.bashrcexec $SHELL

Any available Ruby version can be installed using Rbenv. Use this command to list the available Ruby version.

rbenv install -l

This is the output you will get-

With this example, we will be installing Ruby 3.1.2. Replace the version number with the one of your choice.

rbenv install 3.1.2

Ste the global variable with this command-

rbenv global 3.1.2

Verify installation with this command-

ruby -v

The output you will get will be similar to-

Outputruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

Install bundler with this command-

gem install bundler

Conclusion

When it comes to installing Ruby on Rails, the process may vary depending upon where you are installing it. Hence, where you wish to install Ruby on Rails mac, Ubuntu, or Windows, you will have to follow slightly different steps.

This installation is a necessary step on your journey to learn Ruby on Rails. Practicing will make you perfect at using this framework for web app development.

Ruby on Rails Installation FAQs (Frequently Asked Questions)

Que 1. What is required for Ruby on Rails?

Rails suggests using Ruby version 2.7.0. You should prefer going for the latest Ruby version.

Que 2. What is the difference between Ruby and Ruby on Rails?

There are various differences between Ruby and Ruby on Rails. The primary one is that Ruby is a scripting language, whereas Ruby on Rails, (which is also referred to as RoR), is a widely used web app framework. These both are extremely widely used for programming solutions and tasks.

Que 3. Which framework is Ruby on Rails?

Ruby on Rails is an MVC or a model- view- controller framework. Thus, it provides default structures for a web service, web pages, and a database (DB).

Course Schedule

Course NameBatch TypeDetails
Ruby and Rails Training
Every WeekdayView Details
Ruby and Rails Training
Every WeekendView Details

Drop Us a Query

Fields marked * are mandatory
×

Your Shopping Cart


Your shopping cart is empty.