`eager_autoload` needs to be triggered for nested constants.
When `ActiveRecord::Associations.eager_load!` is called, it eager loads the `Preloader` but does not trigger a `eager_load!` on the `Preloader` itself. A eager loaded component is responsible to forward the `eager_load!` call to nested constants that make use of `eager_autoload` as well. This will also resolve the occasional `NameError` that we've observed in production: ``` NameError: uninitialized constant ActiveRecord::Associations::Preloader::BelongsTo ```
This commit is contained in:
parent
6d6249b1c1
commit
fc4c15d823
|
@ -224,6 +224,11 @@ module ActiveRecord
|
||||||
autoload :AliasTracker
|
autoload :AliasTracker
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.eager_load!
|
||||||
|
super
|
||||||
|
Preloader.eager_load!
|
||||||
|
end
|
||||||
|
|
||||||
# Returns the association instance for the given name, instantiating it if it doesn't already exist
|
# Returns the association instance for the given name, instantiating it if it doesn't already exist
|
||||||
def association(name) #:nodoc:
|
def association(name) #:nodoc:
|
||||||
association = association_instance_get(name)
|
association = association_instance_get(name)
|
||||||
|
|
Loading…
Reference in New Issue