Does a "delegated type" work with preloading associations, ala "includes"? This remains a pain point with many polymorphic associations in Rails, but not sure how the new functionality handles if, if it does at all.
Based on this GitHub comment[0], it appears the answer is yes although it requires a little additional customization out of the box to prevent N+1 queries..
In conjunction with Rails's "russian-doll" caching, N+1 queries are (or at least, can be) a good thing.
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.
sbuccini|5 years ago
[0] https://github.com/rails/rails/pull/39341#issuecomment-72725...
inopinatus|5 years ago
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"