The Particle Lab

Illustration for My favourite Ruby Gems

My favourite Ruby Gems

By Marc, 01 Sep 2014

Many tasks that would otherwise take hours or days to build can be easily implemented by simply including the relevant Ruby Gem in your project. Here’s my pick of interesting, useful and most-importantly time-saving gems:

What’s a Ruby Gem? Ruby and particularly Rails have an excellent developer community providing numerous open-source (usually) libraries called Gems. Ruby, Gem, geddit?

Firstly, this very blog would not exist without the wonderful Jekyll, a blog-aware static site generator. I also often use Sinatra for smaller sites that don’t require a large framework like Rails.

When it comes to authentication my first port of call is always Devise. This, along with it’s various extension gems, covers any sort of authentication you could want: Username/Email & Password, Oauth (Facebook, Twitter etc), and Mozilla Persona to name but a few.

FlagShihTzu allows you to store numerous boolean fields in a single numeric database field within ActiveRecord and access them all as though they were individual fields. Kaminari has replaced will_paginate as my pagination gem of choice.

cache_digests enabled a russian-doll style nested caching mechanism within view that can produce huge speed improvements. Read more about this on the signal vs noise blog post how basecamp next got to be so damn fast, under point #2.

ActiveAdmin build beuatiful admin interfaces quickly and simply, which is a great place to start when building the back-end services required for any web application. lograge reduces the Rails log output of most request down to a single easily-parsable line, great for searching and troublshooting.

I’m a big fan of Heroku so obviously I use a few gems that are particularly useful here: rails_12factor enforces a couple of aspects of the Twelve Factor App that Rails/Heroku don’t by default, font_assets ensures your font assets are served with the correct headers to enable browsers (mainly Firefox) to use them correctly, and heroku-deflater gzips just the content that would benefit from such compression without wasting CPU cycles compressing content that does not (it will also serve any existing .gz file).

Many of my favourite gems are solely for use during development. quiet_assets will keep those noisy asset related request lines out of your development log files. meta_request and its RailsPanel Chrome extension gives you access to information about each request in Chrome’s developer tools, here it is in action:

meta_request / RailsPanel

better_errors makes the built-in rails error pages about a thousand percent better by giving you a fully interactive console in your browser at the point of the error, or any parent frame. I recorded a short screencast demonstrating this last year:

These are just the tip of the iceberg, has nearly 90,000 gems listed. What are your favourite gems? Let us know.

Photo: jobafunky

Photo of Marc Roberts, who wrote this blog post

Marc Roberts is Principal & Co-Founder at Neutron Creations, where he rules over all web development and technical direction. His favourite drink is a sweet manhattan and his favourite sandwich is a croque-monsieur. For a plethora of miscellany follow Marc Roberts on twitter.

comments powered by Disqus