Heads up: RSpec-Mocks' #stub_const will define intermediate modules that have not been loaded yet

stub_const can create an unloaded intermediate module and break tests with unexpected method errors. Using the class constant in the path lets Rails autoload the class first.

ActiveRecord: Cleaning up your database with ignored_colums

Unused database columns confuse teams and can linger safely while legacy access is phased out. ignored_columns removes Rails accessors and helps flag fields for later removal.

How to keep using secrets.yml after upgrading to Rails 7.2

Rails 7.2 removes Rails.application.secrets; existing apps can keep secrets.yml by mapping it back with config_for and restoring secret_key_base.

Maintaining custom application tasks in Rails

Large Rails projects benefit from keeping application tasks slim, separating the executable wrapper from the business code, and testing both rake tasks and scripts.

Rails: Pluck across associated tables

pluck can fetch values from joined tables in one query, returning columns from associated records without loading full Active Record objects.

Better performance insights with gem `rails_performance`

rails_performance adds low-effort performance monitoring for Rails apps, surfacing slow endpoints, request timing, query breakdowns, and custom events with Redis-backed dashboards.

How to reload a belongs_to association

Reload a single-record Rails association without reloading the whole parent object; Rails 5+ uses reload_<association>, older versions accept association(true).

Upgrading a Rails app to Cucumber 3

Rails apps upgrading to Cucumber 3 often need gem updates, new tag syntax, and step-definition fixes to avoid parser and argument-mismatch errors.

Using FactoryBot in Development

Dummy development data is faster to create by reusing FactoryBot factories than by using the UI or Rails console records. Defaults, associations, traits, and attribute overrides come along automatically.

Fragment Caching in Rails 7.1+ requires Haml 6

Rails 7.1 changes fragment cache behavior, breaking Haml 5 buffer patches in apps that use caching. Upgrading to Haml 6 is needed for Rails 7.1+ with fragment caching.

Rails: Using normalizes without copying code

Rails 7.1 input cleanup can be reused across models by replacing inline lambdas with callable normalizer classes and a shared base interface.

Ruby / Rails: clone vs. dup vs. deep_dup

Copying Ruby objects can preserve or drop frozen state, singleton methods and mixins, while nested references stay shared unless a true deep copy is used.

Load order of the environment

Rails environment code loads in a fixed boot order, affecting which settings and constants can override others. Knowing the initialization sequence prevents surprises when adding configuration or app code.

CI Template for GitHub Actions

GitHub Actions CI template for Rails apps with parallel RSpec, RuboCop, ESLint, license checks, security scanning, and merged coverage reports.

Webpack(er): A primer

Webpacker integrates webpack with Rails to bundle JavaScript, stylesheets, images, and other assets, with Yarn managing dependencies and loaders handling non-JavaScript files.

Ensure passing Jasmine specs from your Ruby E2E tests

Run Jasmine specs through Rails E2E tests to catch JavaScript failures in regular test runs and verify the runner finishes with all specs passing.

Rails cache connection settings

Redis cache connections in Rails can be tuned with custom timeouts, reconnect behavior, and error handling to avoid slow cache operations and missed connection failures.

Taming icon fonts for use in Rails views

Icon fonts are awkward to use directly in Rails views; helpers and Sass mixins make icon classes, labels, and styling easier to manage.

RSpec: Inferring spec type from file location

RSpec Rails can infer spec behavior from file location, removing manual type tags and enabling request helpers like get and post where appropriate.

Logging multiple lines in Rails without making filtering your logs difficult

Multi-line Rails logs are hard to filter because only the first line gets tagged. Logging each line separately keeps request IDs and timestamps on every line.

routing-filter is broken with Rails 7.1

routing-filter stops working in Rails 7.1 because find_routes now yields lazily, leaving URL segment filters unapplied and routes unrecognized.

Capistrano task to edit staging / production credentials

Editing Rails credentials for staging or production requires server-only secret keys; a Capistrano task opens the decrypted file without copying keys to a dev machine.

Rails: Restrict deletion of a parent record using scoped associations

Block parent deletion when specific child-record conditions exist by combining scoped has_many associations with dependent: :restrict_with_error and ordered callbacks.

Rails: Example on how to extract domain independent code from the `app/models` folder to the `lib/` folder

Move API-client code out of app/models into lib/ to separate domain logic from reusable infrastructure and keep Rails code more maintainable.