Allow one to set `strict_loading_mode` globally
Created by: gjtorikian
Motivation / Background
I was reading through this summary of Rails' strict loading and came across this paragraph:
If you’re very brave, you can opt your entire application into strict loading. (Oddly, there doesn’t seem to be an equivalent of :n_plus_one_only here. I can’t imagine using this.)
In my app, we're setting strict_loading!(mode: :n_plus_one_only)
on individual records; this paragraph made me realize it didn't have to be this way.
This Pull Request has been created because currently, strict_loading_mode
is always set to :all
. It may be preferable for users to have :n_plus_one_only
on an individual model, or even on the entire app.
Detail
This Pull Request adds a new class_attribute :strict_loading_mode
, defaulted to :all
. If it's set to :n_plus_one_only
, that mode is used by default when doing strict loading checks.
Additional information
n/a
Checklist
Before submitting the PR make sure the following are checked:
-
This Pull Request is related to one change. Unrelated changes should be opened in separate PRs. -
Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
-
Tests are added or updated if you fix a bug or add a feature. -
CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.