aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--guides/source/configuring.md4
-rw-r--r--railties/lib/rails/application/finisher.rb7
2 files changed, 11 insertions, 0 deletions
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index 7e00b59f75..994cc31cff 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -88,6 +88,8 @@ application. Accepts a valid week day symbol (e.g. `:monday`).
end
```
+* `config.dependency_loading` is a flag that allows you to disable constant autoloading setting it to false. It only has effect if `config.cache_classes` is true, which it is by default in production mode.
+
* `config.eager_load` when true, eager loads all registered `config.eager_load_namespaces`. This includes your application, engines, Rails frameworks and any other registered namespace.
* `config.eager_load_namespaces` registers namespaces that are eager loaded when `config.eager_load` is true. All namespaces in the list must respond to the `eager_load!` method.
@@ -995,6 +997,8 @@ Below is a comprehensive list of all the initializers found in Rails in the orde
* `set_routes_reloader` Configures Action Dispatch to reload the routes file using `ActionDispatch::Callbacks.to_prepare`.
+* `disable_dependency_loading` Disables the automatic dependency loading if the `config.eager_load` is set to true.
+
Database pooling
----------------
diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb
index 7a1bb1e25c..0599e988d9 100644
--- a/railties/lib/rails/application/finisher.rb
+++ b/railties/lib/rails/application/finisher.rb
@@ -108,6 +108,13 @@ module Rails
ActionDispatch::Reloader.to_cleanup(&callback)
end
end
+
+ # Disable dependency loading during request cycle
+ initializer :disable_dependency_loading do
+ if config.eager_load && config.cache_classes
+ ActiveSupport::Dependencies.unhook!
+ end
+ end
end
end
end