提交 67b79238 编写于 作者: X Xavier Noria

Revert "let environments configure load-related paths"

An app was reported to autoload in config/environments/development.rb,
and this is no longer possible with this change.

I believe it is a better trade-off to leave this for 6.1.

This reverts commit dede40ec.
上级 21a1b187
......@@ -482,6 +482,8 @@ What is described above are the defaults with a newly generated Rails app. There
See also [Autoloading in the Test Environment](#autoloading-in-the-test-environment).
`config.autoload_paths` is not changeable from environment-specific configuration files.
The value of `autoload_paths` can be inspected. In a just-generated application
it is (edited):
......
......@@ -559,12 +559,6 @@ def load_seed
end
end
initializer :load_environment_config, before: :load_environment_hook, group: :all do
paths["config/environments"].existent.each do |environment|
require environment
end
end
initializer :set_load_path, before: :bootstrap_hook do |app|
_all_load_paths(app.config.add_autoload_paths_to_load_path).reverse_each do |path|
$LOAD_PATH.unshift(path) if File.directory?(path)
......@@ -613,6 +607,12 @@ def load_seed
end
end
initializer :load_environment_config, before: :load_environment_hook, group: :all do
paths["config/environments"].existent.each do |environment|
require environment
end
end
initializer :prepend_helpers_path do |app|
if !isolated? || (app == self)
app.config.helpers_paths.unshift(*paths["app/helpers"].existent)
......
......@@ -1751,31 +1751,6 @@ def index
assert_empty Rails.configuration.paths.load_paths - $LOAD_PATH
end
test "autoload paths can be set in the config file of the environment" do
app_dir "custom_autoload_path"
app_dir "custom_autoload_once_path"
app_dir "custom_eager_load_path"
restore_default_config
add_to_env_config "development", <<-RUBY
config.autoload_paths << "#{app_path}/custom_autoload_path"
config.autoload_once_paths << "#{app_path}/custom_autoload_once_path"
config.eager_load_paths << "#{app_path}/custom_eager_load_path"
RUBY
app "development"
Rails.application.config.tap do |config|
assert_includes config.autoload_paths, "#{app_path}/custom_autoload_path"
assert_includes config.autoload_once_paths, "#{app_path}/custom_autoload_once_path"
assert_includes config.eager_load_paths, "#{app_path}/custom_eager_load_path"
end
assert_includes $LOAD_PATH, "#{app_path}/custom_autoload_path"
assert_includes $LOAD_PATH, "#{app_path}/custom_autoload_once_path"
assert_includes $LOAD_PATH, "#{app_path}/custom_eager_load_path"
end
test "autoloading during initialization gets deprecation message and clearing if config.cache_classes is false" do
app_file "lib/c.rb", <<~EOS
class C
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册