[Associations] Start adding `strict_loading`
https://www.bigbinary.com/blog/rails-6-1-adds-strict_loading-to-warn-lazy-loading-associations
Can this ticket be scoped out? Where do we want to use this?
Strict loading is a Rails feature where when you call an association without preloading it, Rails will error to prevent an N+1. This forces us to fix/avoid N+1 issues and improve performance.
We'll start by gradually adding strict loading to commonly used associations on Event and User.
link that @sampoder found: https://jordanhollinger.com/2023/11/11/rails-strict-loading/
I think a good approach to this would be
- Setting
config.active_record.action_on_strict_loading_violation = :log - Working model-by-model to add
self.strict_loading_by_default = true - Temporarily setting
config.active_record.action_on_strict_loading_violation = :raise - Fixing all instances in that model
- Making a PR that fixes N+1 issues and adds strict loading by default to that model (to keep it in place going forward)