Configuring RubyGems and Installing Rails
In this guide we configure our system to work with Ruby Gems and install the Rails gem.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

In this guide, we're going to talk about how to configure your Ruby Gem library. Ruby Gems are code libraries that are used to bring extra functionality to your application. You can use a Ruby gem as a way to install code instead of writing the functionality from scratch.

Configuring Ruby Gems

The first step is to know which version of Ruby Gems is installed in your system.

The command for this is: gem -v. Eg: 2.5.1 (at the time of this video).

I am going to walk you through and do each step with you.

First I am going to switch my Ruby version to 2.4.0 with the command: rvm use 2.4.0

You can verify that your current version is also 2.4.0 with the command: rvm list

Next, to ensure that the right set of Gems are configured for this version of Ruby, Use the command: gem update --system

To see where all the gems are installed use: rvm gemset list. This will give you the location where they are configured. Eg:( found in /Users/admin/.rvm/gems/ruby-2.4.0)

You will note that that these gems are set for default. We do not want to have to reinstall each of the other gems we have installed, so we will change this to the global setting with the command: rvm gemset use global

To see the local gems you have installed use the command : gem list.

If you haven't installed any gems, then your list will be empty.

Last, will we use the command: gem update, to make sure all our gems are at their current version.

Bundler

Before moving on to install Rails we need to install the bundler gem. The command for that is
gem install bundler

The bundler gem will essentially allow you to package all the code libraries that you'll call in your application and have them installed locally on your system. We will use bundler quite a bit.

Nokogiri

The other gem we need to install is Nokogiri, and the syntax is: gem install nokogiri

This powerful gem is probably the largest I've used outside of the rails system, and it helps to do a number of things like communicating with outside services and parsing them. A number of the code libraries we use will depend on Nokogiri. In fact, you need this gem to install Rails. Nokogiri is a huge code library so it will take awhile to install on your system.

Installing Rails

We are now ready to install Rails. The command is: gem install rails.

If you're new to Rails, it's important to understand that Rails is just a gem. It is one of the most powerful gems I've ever come across simply by all the capabilities that are built into it. Rails developers have created a number of Ruby files, generators, methods, classes, and all kinds of code snippets that have been packaged together to create this code library. Succinctly, Rails is Ruby code that has been compiled to work as a web framework.

When you install Rails, the system will also install 33 other gems that are its dependencies.