Blog
Thoughts on software engineering, web development, and technology
The Day I Finally Used EXPLAIN ANALYZE in Production
A cache clear exposed a slow analytics query, and EXPLAIN ANALYZE finally showed exactly where the time was going
Why Relationship Records Weren't Being Created
A missing relationship record turned out to be a three-layer bug involving dropped metadata, the wrong read path, and a callback that was too narrow
Why One Dashboard Page Kept 502-ing
A dashboard page kept timing out because one eager-loading call was pulling 156K records into memory for no reason
The XSS Concern That Wasn't
A code review comment that looked like XSS turned into a useful reminder about ERB escaping and attacker-controlled input
Flash vs Flash.now: The Rails Gotcha That Finally Made Sense
A simple way to remember when to use flash and when to use flash.now in Rails
Two Practical Lessons I Picked Up Building an LTI Integration
A small LTI integration turned into two useful lessons: when to use Stimulus over Turbo, and why exists? is better than find_by for boolean checks
That Time I Fixed a Sneaky N+1 Query in Grade Calculations
How I reduced 40+ database queries to just 5 by fixing N+1 issues in grade calculations
ActiveRecord has_many Joins, DISTINCT, and When ORDER BY Needs a Subquery
Joining has_many multiplies parent rows; DISTINCT dedupes them. In PostgreSQL, DISTINCT plus ORDER BY on joined columns can error—wrap the deduped set in a subquery, then join and order on the outside.
ActiveRecord DISTINCT ORDER BY Error in PostgreSQL and Why a Subquery Fixes It
Seeing `for SELECT DISTINCT, ORDER BY expressions must appear in select list` in PostgreSQL? In ActiveRecord, a `has_many` join can require `DISTINCT`, but ordering by joined columns may need a subquery with `from(subquery, :alias)`.
Concurrent Indexes, Statement Timeouts, and When Migrations Stop Being “Deterministic”
Adding a column and a concurrent index on a huge table: the column landed, the index timed out under migration limits. disable_ddl_transaction!, statement_timeout reset, and idempotent add_column/add_index let a redeploy finish what the first run started.
Built by Sam Lee with
♥