DEV Community

Hayden Rouille
Hayden Rouille

Posted on • Updated on

5 Gems I use in every project

When you're building applications with such a large open source community such as Ruby on Rails, it's important to know what resources you have at hand. RubyGems have thousands of contributors worldwide and is one of the biggest open source language communities around, why wouldn't you take advantage of that?

Here are some gems that I find myself using in every project:

1. Rubocop

A Ruby code standard enforcer and formatter, Rubocop is an essential gem for development, helping you write better code. We all know reading code is harder than writing it, so when you're given a community agreed set of code standards, why not use them?

Remember, writing code can be subjective, and if you're working in a team it's important you all agree on a style guide as it's there to help you.

GitHub logo rubocop / rubocop

A Ruby static code analyzer and formatter, based on the community Ruby style guide.

2. Pry

Debugging can be a pain to say the least. When I was a junior dev, there were countless times where I'd be re-running code with a slightly different puts every time until I could figure out what's wrong. Pry changed all that.

My most used feature of pry is by far binding.pry. By placing a binding.pry within your code, when it's ran your server will stop there and allow you to play around in the console.

Don't stop there though, as it says in the README: Pry is not just an alternative to IRB. Pry gives you access to so much more than just its local variables and methods. For example, you can navigate to completely different classes by just typing cd MyClass or see all the different method calls on a class by ls MyClass. If you've just used Pry for generic IRB commands, you've barely scratched the surface.

GitHub logo pry / pry

A runtime developer console and IRB alternative with powerful introspection capabilities.

3. Webpacker

Webpacker is essentially a wrapper for javascript's webpack that allows rails to manage and bundle javascript code in the same way webpack would.

One of the best features of webpacker (in my opinion) is live reloading. Webpacker will generate a file, bin/webpack-dev-server which when ran will keep an eye on your packs and when saved live reload for you.

Note: webpacker comes as a default gem with any project using Rails 6 and above. If you don't want to use webpacker you can simply run rails new myapp --skip-webpack-install.

GitHub logo rails / webpacker

Use Webpack to manage app-like JavaScript modules in Rails

4. Whenever

Whenever is a way of adding cron-jobs to your rails application. It might be sending out daily emails or checking and updating configurations, but whatever it is, whenever is always a gem I end up using somewhere along the line.

With minimal setup, Whenever will write the jobs for you and you can view them by simply running crontab -l.

GitHub logo javan / whenever

Cron jobs in Ruby

5. Exception notification

No one likes to find out about bugs from the end-user. Whilst this can be unavoidable, exception notifications gives me a a head start fixing them.

When I use devise on projects that require authentication, the warden user key is stored in the session, allowing me to see who's produced the error. Users are impressed when you tell them you're fixing a bug they've encountered without them even raising it, talk about customer service!

GitHub logo smartinez87 / exception_notification

Exception Notifier Plugin for Rails

Some close runners up include Devise, Audited and Fast JsonApi, but they are usually more situational.

This is obviously personal preference, so what gems do find yourself using every project?

Top comments (5)

andrewmcodes profile image
Andrew Mason

Have you tried using Standard (also referred to as StandardRB) instead of Rubocop? I used to be a big Rubocop user but configuring it became a source of bike shedding for several projects. I’ve been using Standard for the past few months and am loving it.

hayden profile image
Hayden Rouille

Hey, no I haven't tried StandardRB, it looks good. What Rubocop configurations did you find tiring, is there less with StandardRB to configure?

panoscodes profile image
Panos Dalitsouris

Cool list, especially the exception_notification looks awesome !!!!

rubyrailsninja profile image


cool post thank you :)

I was expecting more "functional" gems such as devise, elastic search, tracking, pagination, ...

I will try to do this kind of post when having time :)

cheers !

hayden profile image
Hayden Rouille

Hey, thank you.

I also had a list like the one you mention, however they did not attribute to the every project criteria. Maybe I'll do another post for gems I frequently use ;)