Module: Plutonium::Resource::Controllers::EagerLoading
- Extended by:
- ActiveSupport::Concern
- Included in:
- Plutonium::Resource::Controller, ExportCsv, KanbanActions
- Defined in:
- lib/plutonium/resource/controllers/eager_loading.rb
Overview
Preloads the associations and attachments a collection is about to render, without being told which.
Plutonium can do this where a general-purpose Rails app cannot. The
rendered field set is DECLARED — resolved from the policy — rather than
discovered by running a template, and resolving it never touches the
collection. So the exact set of associations a page will read is known
before the query is built. There is no includes list to write, and none
to keep in step with the definition as fields come and go.
Every collection rendering passes its OWN field set, because they differ:
the index renders presentable_attributes, the CSV export renders
permitted_attributes_for_export, and a kanban card renders its
card_fields (falling back to the grid fields). Reading one action's
fields from another's code path resolves the wrong policy method.