all.the.time
I mean, I reach for these gems a lot, when they are useful and/or needed.
A few months ago I posted an article/story about the 27 Gems I use in Almost Every SaaS Project. That received a ton of praise, as well as a little bit of negativity around using *so many* gems.
Rightfully so, blindly installing a whole bunch of gems without worrying about the status of the gems, maintainability and adding even more dependencies to the gem. When I wrote the previous article, I may have been a little exaggerative in that it seemed I would use all of those gems in every project, all of the time. There is always a trade off between writing your own code, and using a gem. Whether it be the maintainability of the functionality or the sheer time/value prop.
Note: This article is based on 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 a few more gems for your arsenal that may help you out!
Foreman — You can use this gem to run your applications from Procfiles. This can be handy when you need to run multiple applications or servers. Suppose you run your Puma webserver, ActionCable, Webpack development server, etc. With forman, you can just foreman .Procfile
to have them all fire up at once.
VCR — This gem lets you record external web requests and replay them in future tests runs. This has two benefits, first you will be recording a known working version of the external request and then future test runs will just locally load up the YAML cassette
VCR stores.
ChartKick — When you need to quickly get a chart/graph in your view, pulling data from ActiveRecord, ChartKick will get you going with one-line(most of the time). If your graph will contain more intricate data or if you need specialized charts you may need to look into building your json response and using a javascript library.
Marginalia — This gem will add a comment to your SQL entries in your log to let you know what application, controller, and action the query may be coming from. This can be useful in debugging queries in your log that may not seem to directly correlate to an action.
BrakeMan — This is one of the few gems that you may not install through your Gemfile, but just through gem install
. BrakeMan is a security analysis tool that will let you know if your application has any security vulnerabilities.
Rack Mini Profiler — This gem here will help you keep your application fast by profiling each web request and showing you the time it takes in each part of your stack through a widget(that is only displayed in development)
RuboCop — Another analysis tool, but this time is linting your ruby files to check how well they are conforming to the Ruby Style Guide.
Concurrent Ruby — This isn’t necessarily a gem that goes in every Gemfile, but when I need to write my own concurrent code(such as data importers) I will reach this bad boy to let me write concurrent Ruby in a style I feel comfortable in. Additionally, many popular gems actually use concurrent-ruby as a main dependency.
OmniAuth — If you need to deal with third party APIs, you will most likely need to deal with OAuth. If you have to deal with OAuth, you should use OmniAuth and their list of open source strategies to make OAuth as simple as a few configuration variables and some response handling.
Paranoia — There are a few gems for the soft-delete
functionality, but this one has always seemed to work the best for me. Soft-deleting is perfect for SaaS applications where associations and audits may still need data to exist, yet for the object to appear deleted in other instances.
MetaTags — This gem is one of those cases where for simple meta HTML tags you can skip a full gem and just content_for/yield a value from controllers. However, if you need a wider array of meta tags, this may be the gem for you.
Pundit — This gem came up in responses to my last post quite a bit. Pundit takes a simple Ruby class approach to authorization within your application. It does a lot less magic than cancancan
and is used heavily by developers who like more explicit codebases. This is where Ruby/Rails developers can begin to diverge on tooling based on implicitness/explicitness preferences.
ActiveAdmin — If your used to Django’s admin interface, or would simply like an admin area to manage data, etc then ActiveAdmin may be just what you need.
Those are some more of the picks I have for gems, do you have any you would like to share(even a shameless plug of your own)? Just comment below!