Ruby’s precious gems
Tags: rails, ruby, gems, beginners
Published: 2021-04-06 08:21:17

# Welcome  
Hello, dear friends, Ruby enthusiasts, and coders. I am glad you found time to spend your precious time to learn a bit more about precious Ruby and its precious “Gems”. So, let’s get to it.
  
---
  
# What are Ruby gems?
  
A Ruby gem is a package that can be downloaded and installed as a part of your application you’re developing. They actually contain a packaged Ruby application or library. When you require an installed gem you’re adding extra functionality to your Ruby program.
Gems can be used to extend or modify the functionality of your Ruby applications. What is great about them is that they can be distributed and shared with other Ruby coders so that they can use them in their own applications.
  
---
  
# Examples of gems
  

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ylnyiyvm9jhjypkdwkkz.png)
  
Gems make our life much easier, to the extent that we can save not hours, but weeks or months of coding time. By just adding the required gem to our application, we can quickly and easily integrate the feature it provides to our fresh baked application.
Here are some of the extra functionalities, ruby gems can provide for our applications:
  
- _**Authentication**_ (Devise, ruby-jwt, omniauth, etc)
- _**Authorization**_ (cancancan, pundit)
- _**Testing**_ (Rspec, shoulda-matchers, capybara, faker, etc.)
- _**Search**_ (elasticsearch)
- _**Admin panels**_ (activeadmin, administrate)
- and hundreds and thousands of more and more…
  
---
  
# Where can I find them?
  

  
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tujfkh1phuu03ry4k5v.png)
  
You surely know about npm — node package manager and that it is a central point where you can search for and learn about javascript redistributable packages.
For Ruby gems, you can go to the RubyGems website. It is the Ruby community’s gem hosting service, where you can find, learn about, install them and publish your own gems.
There is yet another service where you can search for gems by category. It is “The ruby toolbox”, and it is a catalog of gems that keeps track of popularity and health metrics to help you choose a reliable library.
  
---
  
# Managing Ruby Gems
  

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ls96cjbzfof83togpza.jpg)
  
Of course, to manage the gems you use in your application you need a package manager. Something should be keeping track of the gems you installed and their versions. That’s where the Bundler comes in. Well, Bundler is a tool for dependency management. It provides a consistent environment for your projects by tracking and installing the exact gems and versions that are needed.
Usually, you list the gems you use in a file called “Gemfile”. That’s the starting point where the Bundler analyzes and installs all the required gems to be used in the application.
  
Here are some of the commands you would use to manage your gems in a project:
  
- _**gem list**_: Lists installed gems. Accepts an argument for filtering gems by name (example: gem list active)
- _**gem install <name> -v <version>**_ : Allows you to install a specific gem version (example: gem install sinatra -v 2.0.0)
- _**bundle install**_: Installs all the gems listed in the Gemfile
- _**bundle update**_: Installs all the gems, and if required, updates specific gems to the latest version available.
  
---
  
# Conclusion
  

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ag7rm2i9yfcfbb4sucj.jpg)
  
Before using a specific gem, please read its docs and analyze it thoroughly. The thing you should be considering is whether it exactly meets your requirements and whether it does not break your functionality when you decide to extend some of the features in your application.
  

I mean it must not be a burden when you decide to extend some functionality or add a new feature to your application. If you are suspicious that it can, then search for another one that fits best for it. For that, you have to carefully read the docs it provides on its website or its GitHub Readme file. It is better if you try using it in a small sample application, before integrating it into your desired application.
  

Here we come to the end of our article about Ruby gems, how to cook and how to eat them. I hope so much, it can be of use for anyone interested in Ruby, or maybe especially Ruby on Rails.