1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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:
Yves Senn 2016-11-21 12:41:35 +01:00
parent 6d6249b1c1
commit fc4c15d823

View file

@ -224,6 +224,11 @@ module ActiveRecord
autoload :AliasTracker
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
def association(name) #:nodoc:
association = association_instance_get(name)