This is the second and final part of a blog series about Ruby Gems. In Part 1: An Introduction to RubyGems and Bundler I reviewed what gems were and discussed how to leverage them in your web applications. I promise that Part 2: Essential Gems for Web Applications will be much shorter.
I've been working with Ruby on Rails for many years. I wanted to share with you some gems that I include in almost every project as they are so incredibly useful and well made. For convenience, I've organized them into neat little categories.
Sidekiq - Lets face it. Rails sucks for concurrency. Sidekiq is a robust library for background processing. You can create tasks in worker classes that will be performed asynchronously. These tasks are placed in a queue. Sidekiq uses threads to process many of these tasks at the same. You can perform things like image resizing and email notifications in the background, alleviating the load on your web server.
Roadie - HTML emails are painful to craft. One of the reasons is because you need to inline styles. Roadie is a library that automatically inlines stylesheet rules into a document before sending it by email. Nice and easy.
Roadie Rails - Rails makes it really easy to send HTML email using ActionMailer and ERB templates. Roadie-Rails integrates Roadie to make it even easier to craft good looking emails.
Mandrill Rails - Accept incoming webhooks from Mandrill, allowing you to process inbound email in your application. This is very useful for implementing features, such as reply by email.
Carrierwave - Provides a way to upload files including multi-file uploads. By default it works with the file system but it can be configured to use services such as Amazon S3 for file storage. It also includes a library for manipulating images so that you can do convenient things like process thumbnails on upload or in background jobs.
Fog AWS - Add support to your application for connecting with Amazon Web Services. This gem can be used in conjunction with Carrierwave to upload files to Amazon S3. Carrierwave has detailed instructions for doing so in their README file.
RSpec - Add support for behaviour-driven development. RSpec uses a domain-specific language (DSL) for testing. Not everyone likes that. I prefer it as it lets me write tests that are easy to read, even for non-developers.
RSpec-Rails - Integrates RSpec with Rails so that you don't have to.
Factory Girl - A fixtures replacement. Easily setup Ruby objects to use in your tests.
Database Cleaner - A library that includes strategies for cleaning your test database during testing so that you can keep your database in a clean state minimizing side effects that may impact testing.
Capybara - An acceptance testing framework. Capybara uses Selenium to drive your app, allowing you to simulate user interactions like clicking and filling out and submitting forms.
User Authentication and Authorization
Devise - An incredibly feature rich and configurable authentication solution for Rails based on Warden. Devise includes 10 modules for database authentication, omniauth authentication, email confirmation of new accounts, password reset, user registration, remembering user from saved cookie, tracking sign-in count, timestamps, and IP addresses, expiring sessions, validating emails and passwords, locking accounts. Use any or all of these features and customize them to your needs. You can even customize the emails that are generated.
Pundit - An object-oriented authentication mechanism. In a nutshell, you can create policy classes that you govern if users can list, show, create, update, or delete instances of models. You can also use Pundit to scope queries based on users or roles. Pundit can even throw exceptions if controllers do not implement an authorization call in their methods.
Rolify - Rolify is a role management library. It allows you to create roles, assign them to users, and query if users have roles. That's it. It does no authorization and I like it that way as I prefer to use Pundit for that.
HTTParty - If I absolutely must use HTTP to communicate with web services on the server in Ruby, then I use this library to do it. It has a nice API for dealing with HTTP.
I recommend that you checkout the Github pages for each of the projects listed here. You can also checkout RailsCasts for video tutorials on most of these libraries. Even though most of them will be a couple years old by now, most of these are mature libraries and have not changed much over the years.