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


6 responses to “Install and Use Ruby Gems

  1. Hey! This post couldn’t be written any better! Reading through this post reminds me of my previous room mate! He always kept chatting about this. I will forward this article to him. Fairly certain he will have a good read. Many thanks for sharing!

  2. Pretty section of content. I just stumbled upon your site and in accession capital to assert that I acquire actually enjoyed account your blog posts. Any way I will be subscribing to your feeds and even I achievement you access consistently rapidly.

  3. This is very interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your fantastic post. Also, I’ve shared your web site in my social networks!

Leave a Reply

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

Enter Captcha Here : *

Reload Image