by sbuccini · 5y ago · 0 comments
My favorite new feature is "delegated type" in ActiveRecord to offer a new way to map class hierarchies onto database tables. I wrote a blog post about it[0], but the actual PR is very readable as well[1].
[0] https://www.stevenbuccini.com/how-to-use-delegate-types-in-r...
[0] https://github.com/rails/rails/pull/39341#issuecomment-72725...
This sounds counterintuitive; but, in the common case of read-heavy services, N ≐ 0 after the first access. When something changes, subsequent views end up loading & rendering the one record that changed, instead of preloading an entire collection.
However, achieving this in practice requires some care in the nesting of view partials and records.
c.f. DHH in https://www.youtube.com/watch?v=ktZLpjCanvg&t=4m27s "N+1 is a feature"
I missed this. Going through the changelogs the only thing I found is support case-insensitivity for pg UUID types. Is that what you meant?
I really think that not supporting UUID PKs is one of biggest issues with Rails. You can go around it and maybe even use a gem for it, but that's still a bit risky.