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 . 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 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), .
Here are the 25 gems:
- — 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.
- and — 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.
- and — 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.
- — 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.
- — Allows quick ordering and sorting of sibling elements. Instead of using a sequential position integer, it uses big numbers to sort faster.
- — Allows you to use the Bootstrap HTML/CSS framework to quickly build a usable interface for the application.
- — Used in obfuscating the auto-incremented primary ID used in rails objects from the URL.
- — 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 .admin? %><h1>Welcome back admin</h1><%- else %><h1>Welcome back pal</h1><%- end %>…would become
- if .admin?h1| Welcome back admin- elseh1| Welcome back pal
- — 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.
- — This gem handles pagination and it’s edge cases. It also includes templates that already work with Bootstrap.
- and — Combined these two gems will allow you to upload assets such as avatar images through your application into AWS S3.
- — This will help standardize around common issues found when calculating money as well well providing a few template helpers.
- — 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.
- — 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.
- — 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.
- — 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.
- — 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.
- , , — 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.
- — This gem will open mail in the browser instead of attempting to send mail in the development environment.
- — 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?