Writing
Ruby Gems I Use in Almost Every Rails Project, Refreshed
My list of the gems I used in almost every Rails project, rechecked. Most still earn their place, more than a third changed or were replaced by something built into Rails, and every gem is a dependency worth judging before you add it.
By Ka Lun Chan · Web development / Engineering judgment
Which Ruby gems still earn a place in a Rails app?
Most of my original list still does: rspec-rails, factory_bot, faker, rubocop, bullet, friendly_id, meta-tags, sitemap_generator, cancancan, Sidekiq and simple_form are all actively released. More than a third changed. Some are unmaintained, and Rails itself now covers authentication, file uploads, background jobs, recurring tasks and health checks, which used to need a gem.
I first wrote this on my old blog. This version keeps the list and the advice that held up and updates what changed. My original post opened with “Don’t reinvent the wheel and contribute to Ruby,” and that still holds, because a good gem saves days. What I’d add now is that every gem is a dependency you maintain, patch and eventually replace, so the bar for adding one should be higher than “it saves an afternoon.”
| Gem | Status now | What I’d use |
|---|---|---|
faker | Repository moved to faker-ruby/faker | Keep it, update the link |
populator | Unmaintained, repository archived | insert_all plus faker |
guard-rspec | No release in a long time | Optional. Editor test runners cover most of it. |
better_errors | Still works, releases are rare | Start with web-console, which Rails ships |
devise | Moved to heartcombo, on 5.x | Keep for complex auth. Try the Rails generator first. |
exception_handler | Last release predates Rails 7 | Rails exceptions_app or static error pages |
health_check | Moved, docs cover Rails 5 and 6 | Rails /up, plus your own checks |
Sidekiq | Actively released | Keep at scale. Solid Queue is the Rails default. |
whenever | Actively released | Solid Queue recurring tasks if you use it |
CarrierWave | Maintained | Active Storage for new apps |
will_paginate | Maintenance mode | pagy or kaminari |
impressionist | Looking for maintainers | Analytics, or a counter column |
active_model_serializers | 0.10 maintenance only | A maintained serializer or plain as_json |
simple_token_authentication | Rare releases, never audited | has_secure_token or a vetted API auth gem |
rails_amp | Supports Rails 4.1 to 5.0 | Drop it. AMP is optional for Google. |
webpacker | Retired by the Rails team | importmap, jsbundling-rails or Shakapacker |
Which testing and development gems still hold up?
The core set does. rspec-rails, factory_bot_rails, shoulda-matchers, rubocop and bullet all had releases recently. faker moved to a new home, populator is dead, and guard-rspec and better_errors are now optional.
- faker moved from its original owner’s account to the faker-ruby organization. Same gem name, so only the link changed.
- populator says in its README that it’s no longer maintained, and the repository is archived. Rails’
insert_alldoes the mass insert, and faker fills in the data. - database_cleaner is still maintained. Rails wraps each test in a transaction by default, so I reach for it only when a test needs a real commit.
- guard-rspec hasn’t had a release in a long time. It may still work for you, but many editors can now run the spec under the cursor.
- better_errors still works, but its releases are rare, and the default Rails Gemfile already includes web-console for a console on the error page.
- bullet still flags N+1 queries and unused eager loading. The fixes it suggests are covered in how to find and fix slow SQL queries.
# db/seeds.rb: what populator used to do, with Rails and faker
rows = Array.new(10_000) do
{ title: Faker::Lorem.sentence, body: Faker::Lorem.paragraph,
created_at: Time.current, updated_at: Time.current }
end
Post.insert_all(rows) # one INSERT, skips validations and callbacksDo the SEO and authentication gems still make sense?
The SEO gems do, unchanged. For authentication, Devise, OmniAuth and CanCanCan are all maintained, but Rails 8 now generates a basic sign-in system, so Devise is no longer the automatic first choice.
friendly_id, meta-tags and sitemap_generator are all actively released. Slugs, meta tags and sitemaps are plumbing every content site needs, and none of it is in Rails.
Devise moved to the heartcombo organization and is on its 5.x line. Its own README advises against using it for your first Rails app, because it assumes you understand the framework. That advice now has a better answer: the Rails security guide describes bin/rails generate authentication, which adds the models, controllers, views and migrations for sessions and password reset. You own that code, which makes it easy to read. I’d still pick Devise when an app needs confirmable accounts, lockouts and several sign-in strategies out of the box.
OmniAuth is on version 2, which protects the request phase (POST /auth/:provider) against CSRF by default. If you’re upgrading old login links that used GET, they need to become POST buttons. CanCanCan is still released and still does the job.
What about error handling and health checks?
exception_notification and New Relic’s agent are still maintained. exception_handler and health_check have both stalled, and Rails now has a built-in /up endpoint that covers the basic health check.
exception_notification still sends errors to Slack and email, and newrelic_rpm is released regularly. exception_handler hasn’t had a release since before Rails 7, so for custom error pages I’d use the static pages in public/ or point config.exceptions_app at your own routes.
The health_check gem moved to a new organization, and its README still talks about Rails 5 and 6. New Rails apps generate a /up route served by Rails::HealthController. Know its limit: it returns 200 if the app booted and 500 otherwise. It doesn’t check the database, cache or queue, so if your load balancer needs those, add a small controller that does.
Which application gems has Rails replaced?
Background jobs, cron schedules and file uploads now have defaults in Rails: Solid Queue, its recurring tasks, and Active Storage. Sidekiq, whenever and CarrierWave are all still maintained, so this is a choice, not a forced migration.
The Active Job guide says Solid Queue is the default queue backend from Rails 8, and it runs on your database instead of Redis. Sidekiq is still actively released and a strong choice for heavy job volume. For a smaller app, dropping Redis is one less service to run. Solid Queue also handles recurring tasks, which is what I used whenever for:
# config/recurring.yml: Solid Queue's version of a whenever schedule
production:
nightly_sitemap:
class: GenerateSitemapJob
schedule: every day at 3am
clear_expired_sessions:
command: "Session.where(updated_at: ...30.days.ago).delete_all"
schedule: every hourFor uploads, Active Storage attaches files to records and stores them in S3, Google Cloud Storage or local disk, so I’d start a new app there. I’d keep CarrierWave in an existing app that uses it well.
Three others need replacing. will_paginate is in maintenance mode, so pagy or kaminari for new work. impressionist is looking for maintainers and hasn’t had a release in years. Page views belong in your analytics, or a counter column if the app needs the number. For soft delete, acts_as_paranoid is still released. discard is worth a look for new code: instead of a default scope and an overridden destroy, it adds explicit discard methods and scopes, so nothing surprising happens in a query.
draper, simple_form, has_scope, Split and httparty are all still released and still useful.
What changed for APIs and front-end gems?
The most. active_model_serializers is maintenance only, simple_token_authentication is rarely released, Webpacker was retired, and AMP is no longer something Google requires. react_on_rails is the one still in active development.
The active_model_serializers README says the 0.10 line is a maintenance version and that a 1.0 isn’t going to happen. It lists alternatives. simple_token_authentication carries a badge saying it has never had an independent security audit, which matters for code that guards an API. Rails’ has_secure_token covers simple cases.
The Webpacker README says it has been retired. It recommends jsbundling-rails or import maps, and points to Shakapacker for teams that want to stay on webpack. rails_amp supports Rails 4.1 to 5.0 only, and Google’s page experience update made AMP optional for Top Stories. I wouldn’t build AMP pages for a new site. react_on_rails is still in active development, and I cover where it fits in React on Rails.
How should you judge a gem before adding it?
Check whether Rails already does it, whether the gem is maintained, and what it costs to remove later. Then run bundler-audit in CI so you hear about security advisories in the gems you already have.
- Check the framework first. About ten gems on my original list now overlap with something built into Rails.
- Read the README’s top and the release history. Maintenance mode, “looking for maintainers” and “retired” notices are usually right there.
- Check which Rails versions it supports. A gem stuck on an old major version will block your next upgrade, which is the theme of what changed when upgrading Rails.
- Estimate the exit cost. A gem that adds a DSL to every model is harder to remove than one called in a single service object.
- Run bundler-audit on every build. It checks
Gemfile.lockagainst known advisories, and new Rails 8.1 apps include it.
# Check Gemfile.lock against the Ruby advisory database
bundle exec bundler-audit check --update
# New Rails 8.1 apps ship a binstub and run it in bin/ci
bin/bundler-auditAn advisory still needs a decision, and I wrote about that in how I triage a critical vulnerability. Sometimes the right call is to skip a gem altogether, as in the architecture you don’t build. The “contribute to Ruby” half of my original line matters more now too. Several gems on this list are kept alive by one or two volunteers. If you depend on one, a bug report with a failing test or a small pull request is the cheapest way to keep it healthy.
Sources
Checked in November against each gem’s GitHub repository and rubygems.org release history, the Rails guides and API documentation, the Solid Queue README and Google Search Central. The table and the recommendations are mine.
- faker on GitHub (faker-ruby organization)
- populator on GitHub: unmaintained notice
- Rails API: ActiveRecord::Relation (insert_all)
- Devise on GitHub (heartcombo)
- Ruby on Rails Guides: Securing Rails Applications (authentication generator)
- OmniAuth on GitHub: CSRF protection
- Rails API: Rails::HealthController (/up)
- health_check on GitHub
- Ruby on Rails Guides: Active Job Basics (Solid Queue default)
- Solid Queue on GitHub: recurring tasks
- Ruby on Rails Guides: Active Storage Overview
- will_paginate on GitHub: maintenance mode notice
- impressionist on GitHub: looking for maintainers
- discard on GitHub: why not paranoia or acts_as_paranoid
- active_model_serializers on GitHub: status of AMS
- simple_token_authentication on GitHub: security notice
- Webpacker on GitHub: Webpacker has been retired
- Google Search Central: more details on the page experience update (AMP and Top Stories)
- bundler-audit on GitHub
- Ruby on Rails Guides: Rails 8.1 release notes (bin/ci with bundler-audit)
Short answers
Should I use Devise or the Rails authentication generator?
For a new app with plain email and password sign-in, start with bin/rails generate authentication, which Rails 8 ships and which gives you code you own and can read. Devise is still maintained and makes sense when you need confirmable accounts, lockouts or several sign-in strategies out of the box. Its own README advises against it for a first Rails app.
Do I still need Sidekiq and whenever in a new Rails app?
Not necessarily. Solid Queue is the default Active Job backend from Rails 8, runs on your database instead of Redis, and handles recurring tasks in config/recurring.yml. Sidekiq and whenever are still maintained, and Sidekiq remains a strong choice for heavy job volume.
What replaced Webpacker in Rails?
The Rails team retired Webpacker. Its README recommends jsbundling-rails or import maps, which new Rails apps use by default, and points teams that want to stay on webpack to Shakapacker.
How do I check my Ruby gems for security vulnerabilities?
Run bundler-audit, which checks Gemfile.lock against the Ruby advisory database. New Rails 8.1 apps include it and run it in bin/ci. Add it to your CI so every build checks for new advisories.
Audit your Gemfile
Open your Gemfile, run bundler-audit, and check the last release date of every gem you don’t recognise. Anything that Rails now covers, or that nobody has released in years, goes on the list for your next upgrade.