• 30 minutes
  • Medium

Free online content available in this course.


Got it!

Last updated on 9/5/18

Log in or subscribe for free to enjoy all this course has to offer!

Course introduction

Welcome to this course on RubyGems! Let's take a look at how to install RubyGems and get access to enhanced functionality.

What is RubyGems ?

RubyGems is a package manager for the Ruby programming language. It allows you to distribute Ruby programs and libraries in a self-contained format called a gem. The RubyGems tool is
designed to easily manage the installation of gems as well as the server for distributing them.

What's a package manager? 🤔

Package managers typically maintain a database of software dependencies and version
information to prevent software mismatches or missing prerequisites.

Get RubyGems

You can find and download RubyGems here.  Once the package manager is downloaded, use the CLI, or command line interface, to interact with a tool called gem. Gem will then install and manage libraries (the gems themselves).

In your rails console type:

gem install devise

Next, locate your Gemfile.  The Gemfile is usually in the main directory of your project but it can be wherever you want it.  It's a base file that comes standard with Modern Rails applications. This file is the list of dependencies you need in order to be able to run the application properly. The Gemfile just tells the application what to download, somewhat like instructions. This way you can transfer the application and run it elsewhere without having to transfer high amounts of library and framework data.

Install a gem

To install a gem, open your rails console and type the install command seen in the image below. In the example below you can see how to install a popular authentication gem called "devise":


  1. The top line tells the Gemfile which library it will need to download and the preferred version. Once the application is run, it will go and grab everything listed in the Gemfile, then install it.

  2. The second line tells the application to add this Ruby library immediately to the application.

You can repeat this process for other gems.

In the image below, you can see a typical Gemfile. Note that the version is specified on the right. If no version is specified it will attempt to download the most recent one.

A typical Gemfile
A typical Gemfile

Why use Gems?

Ruby gems will be an absolute must as you progress through the Ruby path. They can provide
enhanced functionality relatively easily to your application. Typical uses include:

  • map APIs

  • adding the ability to use React with Rails (react-rails)

  • making authentication simpler (devise).

To get you started, here is a list of other commonly used Gems in the Ruby language.  Explore and enjoy!  

Example of certificate of achievement
Example of certificate of achievement