Rob Race

@rob__race

25 Ruby Gems I use in almost every SaaS project

and pretty much can’t live without

The Rails community thrives on its open source gems. Implementing a well written, well tested and vetted gem can make the difference between days and weeks of development of new features.

Not every gem is great, but I wanted to share a list of gems that I have used on nearly every recent SaaS project I have worked on.

Note: This article is an excerpt from a chapter in my upcoming book Build A SaaS App in Rails 6. The book guides you from humble beginnings through deploying an app to production. The book is now in pre sale, and you can grab a free chapter right now!

Also, the beta for my new project Pull Manager is has been released. If you’re losing track of pull requests, have old ones lingering around or would just love a dashboard that aggregates these requests over multiple services (Github, Gitlab, and Bitbucket), check it out.

Here are the 25 gems:

  • local_time — This is a gem that includes a view helper and javascript helper to display relative time (i.e. ‘updated 2 minutes ago’). Not only will it format the string, but will update the string on the client side as time goes on.
  • devise and devise_invitable — Devise is the authentication library most used in Rails for the past few years. While there are some up and coming libraries to provide authentication services, the support around Devise and it’s ease of use make it great to move quickly on your SaaS application. Devise Invitable is an add-on gem that will allow you to have an invitation system to have users invite other users to your application.
  • rolify and cancancan — Rolify allows the application to assign roles such as User or Admin on a User object. Then CanCanCan allows you to take those roles and apply authorization policies.
  • paper_trail — This will allow you to set up audit logs on particular models so you can see what users made a change. Using that information to be displayed within your application in an activity log or just used as a way to troubleshoot changes.
  • ranked-model — Allows quick ordering and sorting of sibling elements. Instead of using a sequential position integer, it uses big numbers to sort faster.
  • bootstrap-sass — Allows you to use the Bootstrap HTML/CSS framework to quickly build a usable interface for the application.
  • friendly_id — Used in obfuscating the auto-incremented primary ID used in rails objects from the URL.
  • slim-rails — Instead of using HTML markup with Ruby code embedded, Slim is another templating language that allows you to write simple markup, without the need for closing tags. For example:
<%- if @user.admin? %>
<h1>Welcome back admin</h1>
<%- else %>
<h1>Welcome back pal</h1>
<%- end %>

…would become

- if @user.admin?
h1
| Welcome back admin
- else
h1
| Welcome back pal
  • Sidekiq — This gem allows you to run background jobs, backed by a Redis queue. Instead of running tasks like sending emails on the main request loop. You can drop it into a Sidekiq job to run in the background.
  • kaminari — This gem handles pagination and it’s edge cases. It also includes templates that already work with Bootstrap.
  • paperclip and aws-sdk — Combined these two gems will allow you to upload assets such as avatar images through your application into AWS S3.
  • money-rails — This will help standardize around common issues found when calculating money as well well providing a few template helpers.
  • ransack — A search abstraction that will allow you to create simple forms that can search through tables. Such as a search form on a users index page.
  • slack-notifier — Simple Slack API integration tool to quickly send a message to a Slack Webhook. Tiy can use this to send notifications to your own Slack when a new user signs up or in other areas. You may use more in-depth gems if more than Webhook integrations are needed with Slack.
  • premailer-rails — This helps with CSS inclusion into mail templates. Gmail will commonly break email templates based on how they can ignore included CSS. This gem automatically merges styles into the markup tags to work in Gmail.
  • griddler — This tool allows you to parse email received through a mail sending API. I have used this gem with its Sendgrid companion gem, but you can choose other email providers as well.
  • rollbar — This gem allows you to send exceptions to a third-party exception aggregator. Otherwise, you would need to set up your own exception notification process or spend all your time watching Rails’ logs.
  • rspec-rails, factory_bot_rails, simplecov — I personally like to use RSpec over the default Rails test framework. I find it easier and quicker to reason about model factories over fixtures for the more complex model associations. SimpleCov is an easy way to keep track of your test coverage.
  • letter_opener — This gem will open mail in the browser instead of attempting to send mail in the development environment.
  • rack-cors — This gem will help set up CORS rules. This will be of use if accessing JSON requests from domains that are not the current Rails’ app configured domain name. This is helpful if at any point a request from front-end code is sent to your Rails application.

Those are my pick for gems, what are yours?

More by Rob Race

Topics of interest

More Related Stories