rails

Stimulus: bulk selection + Turbo batch action

For batch operations, Stimulus can manage the UI state (select all, indeterminate checkbox) while Turbo submits a regular form. This keeps the server in charge of authorization and the UI simple.

Image upload with preview and Rails Direct Upload

Direct uploads to cloud storage bypass the Rails server, improving performance and reducing server load. I use ActiveStorage's Direct Upload feature to get presigned URLs from Rails, then upload files directly to S3 from the browser. The React compone

Stimulus controller for dynamic form interactions

Stimulus brings just enough JavaScript to make static Rails views interactive while staying close to the HTML. Controllers connect to DOM elements via data-controller, and actions bind to events with data-action. I use Stimulus for client-side validat

Database constraints for data integrity

While ActiveRecord validations catch most invalid data, database constraints provide a safety net that prevents invariant violations even when validations are bypassed. I add null: false constraints for required columns, unique indexes for uniqueness

Background Job Backpressure with Queue Depth Guard

When downstream systems degrade, jobs pile up and amplify outages. Add a simple “queue depth guard” so non-critical jobs skip or reschedule instead of making the backlog worse.

Inline form validation feedback via Turbo Streams

When forms live inside a Turbo Frame (modal or inline edit), validation needs to feel immediate without a full-page refresh. I render the form inside a frame with an ID like post_form. On submit, create/update returns status: :unprocessable_entity and

Turbo Streams: partial replace with morphing (less jitter)

When replacing DOM chunks, morphing reduces flicker and preserves focus/selection. If you enable morphing, prefer server-rendered HTML that’s stable and keyed. It’s a subtle but meaningful quality improvement.

Per-account stream scoping to prevent “cross-tenant” updates

Broadcasting is powerful, but it’s also easy to accidentally leak updates if everyone subscribes to a global stream. My default is to scope streams to a tenant boundary (like Current.account) and a resource. That means turbo_stream_from [current_accou

Use data-turbo-action to control history (advance vs replace)

Turbo Drive records visits in browser history. For some interactions (like typing through search results), you don’t want every click to create a new history entry. Turbo supports data-turbo-action='replace' to replace the current history entry instea

CurrentAttributes for Request-Scoped Context

I use ActiveSupport::CurrentAttributes any time I need request-scoped context without turning my app into a tangle of thread-local globals. In Current, I define the attributes I care about (member, request_id, remote_ip) and I use the resets hook to c

Rails concerns for shared controller behavior

Concerns extract shared logic from controllers into reusable modules, keeping controllers DRY. I create concerns for cross-cutting features like authentication, pagination, or error handling. The extend ActiveSupport::Concern pattern provides included

Service objects for complex business logic

As business logic grows, controllers become bloated with transaction management, error handling, and cross-model orchestration. Service objects extract this complexity into dedicated classes with a single public method (usually call), keeping controll