~/talk

An ActiveRecord Rewrite: the Story Behind the Attributes API

Talkat RailsConf 2025 · 2025-07-08..07-10· [ruby-on-rails]
slides:none on file

A refactor rearchitects ActiveRecord type casting into an Attributes API with per-attribute objects delegating to type objects, replacing spaghetti overrides across modules. It starts as a huge PR — 37 files changed — and addresses decades of leaking behavior, closing many bugs; initial maintainability gains cause a perf hit of thousands of allocations but get reclaimed by lazily instantiating objects, dropping an example from 800 Ruby allocations reduced to 60. The work is extracted to active model and stabilizes upgrades.

AI-written summary · about

  1. 0:00Attributes API rewrite intro
  2. 1:45Origins of Attributes API
  3. 3:33Problems with monkey patching
  4. 5:17Type casting before rewrite
  5. 7:27Type casting spaghetti code
  6. 8:52Refactoring to maintainable Ruby
  7. 11:03Performance vs maintainability
  8. 13:49Maintainability over speed
  9. 15:37Open source contribution tips
  10. 17:44Final thoughts
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.