-
-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Active Record strict loading by default #1119
Comments
@MatheusRich overall, I like this idea. If I'm understanding this correctly, enabling this feature will result in ActiveRecord::StrictLoadingViolationError being raised anytime an attempt to lazily load records was made. However, what do we do in the case where we desire lazy loading, as mentioned in your example? This article mentions a few approaches to enabling/disabling it on a more granular level. My concern is that a developer my not know where the error is coming from, and decide to simply disable |
@stevepolitodesign In those cases, I'd say the developer could disable it on a model/association basis. That being said, we could enable make it just log errors, instead of raising them # development.rb:
config.active_record.action_on_strict_loading_violation = :log |
Interesting! I didn't realize logging was an option.
I was thinking the same thing, although, there could be cases in which one would want to lazy-load a query in a specific context? It looks like you can call strict_loading on a specific query to have the feature enabled. It looks like we could pass |
In an effort to drive out the implementation, we start with a feature test asserting the desired developer configuration. Co-authored-by: Dimiter Petrov <[email protected]>
@crackofdusk and I are working on this in https://github.com/thoughtbot/suspenders/tree/1119-enable-active-record-strict-loading-by-default |
Most Rails projects I've worked on don't use N + 1 queries as a feature for caching. Should we use
by default then?
The text was updated successfully, but these errors were encountered: