GitHub's ViewComponent claims to be about 10x faster than Rails partials. Running its benchmarks shows regular components are roughly 5x faster, and adding memory benchmarks shows partials use at least 3x more memory. A real gain, worth weighing against a new directory structure and extra files.
A scoped belongs_to makes it possible to join through a polymorphic association in ActiveRecord, but adding one broke unrelated tests with a confusing FactoryBot error. Because belongs_to is required by default since Rails 5, the scoped association needs optional: true.
Showing an email's subject as a heading in a shared Rails mailer layout sounds trivial, but lazy-lookup translations don't resolve the right scope inside layouts. Digging into ActionMailer's default_i18n_subject points to the fix: build the scope from the mailer name and action_name yourself.
Real Rails apps depend on several processes in development: the web server, Sidekiq, Mailcatcher, Webpack. Instead of starting each by hand, use a Procfile.dev with Foreman, then wrap it in a bin/server script with flags, so every app on the team starts the same way.
Adding analytics calls inline in controllers makes users wait on third-party APIs and slows the whole app. The fix is to move every analytics call into a background job, and, once you send data to several services, wrap them behind a single adapter, which is what B&G's open-source bg-common gem does.
"Skinny controllers, fat models" pushed business logic into ActiveRecord models that were never meant to hold it. Trailblazer operations give each user interaction, like uploading a document, its own class, keeping controllers thin, models as plain data objects, and side effects explicit.
MVC leaves presentation logic with nowhere good to live, so it leaks into views and models. The Decorator pattern fixes that, and Trailblazer's Disposable::Twin makes decorators easy: expose only the properties a view needs, including nested ones, while keeping sensitive data out.
Seed data built from a shared defaults hash works until one value needs to be unique per record, and suddenly every seeded user shares the same Payment. The fix, without monkey-patching Hash: store a lambda as the value and call it as each record is created.
Rails mailer previews are easy until your emails need realistic data. Four approaches, from querying the database to FactoryGirl, rolled-back transactions and plain OpenStruct objects, and the trade-offs of each.
A start-to-finish walkthrough of building drag-and-drop document uploads in Rails without a frontend framework: Cucumber scenarios first, then the UI, then the backend. It uses Refile for storage, DropzoneJS for drag and drop, and a remote form so the task list updates without a page reload.