DEV Community

Riaz Virani
Riaz Virani

Posted on

Ten Ruby gems for Rails you should definitely know about

Whenever I join a new project, I love scooping through their Gemfile and digging about. It's kind of like looking through someone else's apartment only to discover that essential oil diffusers are a thing Those things are amazing!. Weirdly voyeuristic, but incredibly useful to discover new things.

Over the years, I've found that many of us don't know about popular gems that could be of help to us. So here is my list of ten gems you should know about if you don't already. Well, if you already know of them, you've just wasted a few minutes of your life...

Kaminari

Kaminari hooks onto ActiveRecord associations and makes it super easy to page them. Pagy is another option that seems to have a solid API but I haven't tried it yet.

Counter Culture

If you've ever used Rails counter caches (basically help you keep track of the number of related records in a database) but found sometimes you need something a little different. For example, you needed to track the sum of the values in a different table instead of a count of records, then counter culture is for you. I've used it on many projects and it's been rock solid.

LightService

LightService is my favorite gem for organizing business logic. If you've ever heard about railway programming, that's basically what this gem helps you do. Again, used it for years with no issues.

Geocoder

This is hands down the best gem to use if you're trying to convert locations to latitude / longitude coordinates or vice versa. It supports a wide variety of APIs, like Google, etc.

Lockbox

This gem is just too good. It makes it crazy seamless to encrypt the contents of a database field. However, ActiveRecord basically gets to behave as if it's not encrypted.

Money-Rails

Money or as I like to call it...monies. Money rails gives you great tools to manage money and multiple currencies straight up in your Rails application.

ViewComponent

ViewComponent is GitHub's take on expanding upon the partials system in Rails. ViewComponents are a great adaptation to bring the component model that's so common in front end architecture to Rails.

StrongMigrations

Strong migrations runs some linters on your database migrations to make sure you structure your database correctly. It has made I don't shoot myself in the foot many times.

Phony Rails

Just like the money-rails gem above, this gem is all about phone numbers. It makes it really easy to track area codes and standardizes your database to always save phone numbers in the IETF format. Trust me, just use it.

That's it

Wait, you say that's only 9 gems. What can you do? Off by one errors...

Latest comments (0)