Install and Use Ruby Gems

Ruby gems are the ruby third-party libraries that are created for special purpose. For example, in web application if I want to display large number (>500) of data in a single page, I have to use pagination. For this we have special library build in Ruby which is called Gems.

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries, a tool designed to easily manage the installation of gems, and a server for distributing them


Most of public ruby gems are released to and the source code are open source in GitHub. You can directly download and install ruby gems from GitHub source also.

Here is general way to install and use Ruby Gems.

$ gem install gem-name

Here gem-name is ruby gem name. For example will_paginate is a gem which is used for pagination.

Following is the way to install and use ruby gems in Rails.

For Your Information Rails itself is a Ruby Gem.

Add gem to Gemfile and run bundle command in terminal.


gem 'will_pagimate', '~>1.0'

We can also give the specific version of gems while installing. In this example,  in will install latest will_paginate gems which version is greater than or equal 1.0.

Also here is an example how we can install Ruby Gem from GitHub source code.

gem 'activeadmin', github: 'activeadmin'

After adding gem to Gemfile we have to run bundle command in terminal.

$ bundle install


$ bundle

After running this bundle command, your gem is install to Rails and the version of installed Gems and dependencies of all installed gems are locked in Gemfile.lock


One Comment on “Install and Use Ruby Gems”

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here : *

Reload Image