Carrierwave: How to remove container directories when deleting a record

Deleting uploaded files in Rails leaves empty CarrierWave folders behind; a cleanup hook can remove empty parent directories after record deletion.

How to accept more than 4k query parameters in Rails

Large form submissions can fail with hidden Rack::QueryParser::QueryLimitError when total request parameters exceed Rails' default limit. Raising params_limit allows bigger POSTs.

Livereload + esbuild

Live CSS and JS reloading in Rails with esbuild is awkward because generated assets change on every build. A guard-livereload plus livereload-js setup can avoid full-page reloads for stylesheet changes.

How to test a controller concern with rspec-rails anonymous controllers

RSpec controller concerns can be exercised with anonymous controllers, letting shared authorization behavior be tested through real requests without messy dummy routes or rebuilt stacks.

request_store: Per-request global storage for your Rails app

Per-request storage for Rails avoids leaking state between requests when using Thread.current; middleware clears data automatically at request end.

How to update the bundler version in a Gemfile.lock

Bundler versions in Gemfile.lock can lag behind the installed release and break compatibility with older Ruby or Rails setups. Updating bundler and regenerating the lockfile keeps BUNDLED WITH aligned.

Rails: Flagging all cookies as secure-only to pass a security audit

Secure cookies are often required by audits even when a Rails app already uses HTTPS and HSTS. A middleware can add the Secure flag to server-set cookies automatically.

Fuzzy scoping in Rails with PostgreSQL

Approximate string filtering in Rails can find names that nearly match a term by using PostgreSQL trigram similarity and a tunable threshold.

ActiveSupport includes Timecop-like helpers

Rails test helpers let you freeze or shift time without Timecop; travel_to, travel, and freeze_time simplify time-dependent specs when clock progression does not matter.

Heads up: Quering array columns only matches equally sorted arrays

PostgreSQL array queries in Rails match element order, so [16, 17] and [17, 16] are different. Order-independent matching needs normalization or bidirectional containment.

Devise: Invalidating all sessions for a user

Stolen Rails session cookies can remain usable after logout with Devise. Invalidating them requires changing the authentication salt, resetting the password, or storing sessions server-side.

High-level data types with "composed_of"

Rails composed_of bundles several columns into one value object, but immutability, validation, caching, and form handling remain fragile.

Querying model errors in Rails 4

ActiveModel::Errors behaves like a hash for storing and querying validation messages on model attributes in Rails 4.

Creating a Rails application in a single file

Running Rails in one file is useful for quick experiments, debugging bugs, or embedding an app in tests, but version and dependency drift can cause surprises.

Rails: Overwriting default accessors

Customizing Active Record attribute readers and writers can trim or normalize values before persistence, while direct attribute storage bypasses other overridden behavior.

Rails: Passing array values to tag helpers like link_to

Array values in Rails HTML options become space-separated strings, making class helpers accept multiple CSS classes without manual joining.

How to disable logging for ActiveStorage's Disk Service routes

ActiveStorage disk-service requests can clutter development logs with redundant route, record-load, and URL-generation messages. Selective silencing keeps Rails output readable.

Unpoly: Passing Data to Compilers

Rails data can be passed to Unpoly compilers through data-* for simple strings and up-data for objects, arrays, and nested values.

Rails: Preparing scopes with values for creation

where, default_scope, and create_with control which attributes relations apply to new records and how default query conditions differ from default creation values.

Stabilize integrations tests with flakiness introduced by Turbo / Stimulus / Hotwire

Turbo-driven Rails integration tests can become flaky under load because asynchronous renders and requests finish unpredictably. A Stimulus-based lockstep controller coordinates Capybara with Turbo events.

ActiveRecord: validate_uniqueness_of is case sensitive by default

Rails uniqueness validation treats username and USERNAME as different by default, which can conflict with MySQL’s case-insensitive comparisons and unique indexes.

Ruby: Referencing global variables with the built-in English library

Ruby’s special global variables are harder to read and can fail without require 'English', especially in Rails where the library is not loaded by default.

Rails 7 adds #caching? and #uncacheable!

Rails 7 fragment caching gets #caching? and #uncacheable! to detect cache context and prevent accidental caching of helpers or partials that must stay dynamic.

Rails: Assigning associations via HTML forms

Rails forms can assign tag associations in several ways, from array columns to join models; nested attributes keep tag changes in one transaction.