Rails and using gems go hand in hand, and not to mention that Rails is a gem itself, and with it comes a list of gems that are necessary for your project, but the story doesn’t end here. There are thousands of developers who are trying to make Rails development as smooth and efficient as possible, and have developed gems that can save you a huge amount of time, and not only this, it can also ease debugging, and can enhance the overall Rails development experience for you.

Out of those gems, in this article, you will find the five gems that are essential for any Rails project. These are well-tested, and famous in Rails community as well. Not only this, this article will also explain the very simple way of using those gems, and for more information – you can obviously go to gem’s page at Github, link of which is given with the description of each in the following paragraphs.

1. Better Errors:

If you are tired of seeing the red-color-standard-error page, and are looking to find something more elaborative, and flexible, then this is the right gem for you. You can inspect local as well as instance variables right in the comfort of your browser once you have installed this gem.

It also allows you to see Full Stack trace, and the exact line of code that caused you the error(s).

For security reasons, make sure that you use this gem in development only. In order to install this gem, write the following line of code in you Gemfile:

group :development do 
 gem 'better_errors'
end

Head ever to the following link to get more information about this awesome gem. https://github.com/charliesome/better_errors

2. Devise:

No web application is complete without having an authentication system, and to build authentication every time from scratch is a painful process, and also, you are never going to have great fun in reinventing the wheel. So Devise is here to rescue you, another popular Ruby gem.

No web application is complete without having an authentication system, and to build authentication every time from scratch is a painful process, and also, you are never going to have great fun in reinventing the wheel. So Devise is here to rescue you, another popular Ruby gem.

Devise is a rack based gem that provides you a complete authentication system, and at the same time allowing you to alter its behavior as well. Devise is based on MVC pattern, and you get these three components when you install this gem.

It is composed of 10 modules as of writing this article, and it is based on a modularity concept that reads as: Use only what you really need.

You can install it by writing the following line in your Gemfile:

gem 'devise'

For more info, https://github.com/plataformatec/devise

3. Letter Opener:

Almost, every web application sends email for various purposes, and yours is no different. So the application is in testing purpose, and your inbox is filling up with dozens and dozens of emails that are of no use for you after testing. And since, you aren’t the only one facing this problem, and so there exists a solution for it.

Letter Opener gem lets you see the email in your default browser, and this way, you save yourself the pain of receiving, and then obviously deleting the email in your inbox.

You can install it through the following way:

gem 'letter_opener', :group => :development

When you do bundle install, and ready to use it, don’t forget to set the delivery method in config/enviroments/development.rb :

config.action_mailer.delivery_method = :letter_opener

Find more about Letter Opener here: https://github.com/ryanb/letter_opener

4. CarrierWave:

Many Rails application out there receive data from the user in form of files, be it their profile pictures, or some kind of other information. Uploading files, their associated models, validations; if you are supposed to writing all this code by yourself, you are going to hit a brick wall. Why to cause trouble yourself when CarrierWave is there to do the job for you.

CarrierWave provides you a flexible way for handling file uploads in your Rails project, and this gem helps you deal with NoSQL databases as well. So if you are thinking of implementing file uploading in your project; please don’t hesitate – go ahead, and start using it; it’s simple.

gem 'carrierwave'

And after doing bundle install , you can run the generators made available by this gem.

To get more out of this gem, please head over to
https://github.com/carrierwaveuploader/carrierwave

5. Factory Girl:

It’s great to use TDD in your project, but with complex associations, it becomes a kinda pain to prepare the test data through fixtures. Validations like uniqueness, has_many make it hard, and fixtures become no more an option.

FactoryGirl is a replacement for fixtures, and gives you the following features:

1. Awesome definition syntax
2. Can create multiple unique records with one single line.
3. Support for multiple factories for the same class.

Please note that factory_girl is a general gem, and for Rails, you can use a variant of it called factory_girl_rails

Good luck with your Rails projects!

Leave a Reply

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