Home / Rails Style Guide Topics

Choosing Gems for a Rails Application

The documentation that used to be at this address is no longer published, and its source was never released under an open license, so it is not reproduced here. This page is an independent guide to the same topic, written for this archive. It is not the project's documentation and is not affiliated with its authors.

Every gem you add is code you did not write but will have to upgrade, debug and secure. A good style guide does not just list favourite gems; it explains how a team decides whether a gem is worth it.

Questions to ask before adding a gem

Categories that usually pay off

NeedTypical choice
Testingrspec-rails or Minitest, factory_bot_rails, capybara
Code qualityrubocop with rubocop-rails
Security checksbrakeman, bundler-audit
N+1 detectionbullet in development
Background jobssidekiq or a database-backed adapter

Group gems deliberately

source "https://rubygems.org"

gem "rails", "~> 7.1"
gem "pg"
gem "puma"

group :development, :test do
  gem "rspec-rails"
  gem "factory_bot_rails"
end

group :development do
  gem "bullet"
  gem "rubocop-rails", require: false
  gem "brakeman", require: false
end

group :test do
  gem "capybara"
end

Use require: false for command-line tools that never need to be loaded into the running app. It keeps boot time down and avoids surprising side effects.

Keeping the list healthy

  1. Review the Gemfile when upgrading Rails and remove gems the framework now covers itself.
  2. Run a vulnerability audit in CI so known issues fail the build.
  3. Add a one-line comment above any gem whose purpose is not obvious. Future maintainers will thank you when deciding whether it can go.

More on Rails Style Guide Topics

Explore the archive