Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
dede40ec
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dede40ec
编写于
11月 02, 2019
作者:
X
Xavier Noria
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
let environments configure load-related paths
Co-authored-by:
N
Allen Hsu
<
allen.hsusp@gmail.com
>
上级
eb4f36c1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
8 deletion
+31
-8
guides/source/autoloading_and_reloading_constants_classic_mode.md
...ource/autoloading_and_reloading_constants_classic_mode.md
+0
-2
railties/lib/rails/engine.rb
railties/lib/rails/engine.rb
+6
-6
railties/test/application/configuration_test.rb
railties/test/application/configuration_test.rb
+25
-0
未找到文件。
guides/source/autoloading_and_reloading_constants_classic_mode.md
浏览文件 @
dede40ec
...
...
@@ -482,8 +482,6 @@ 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):
...
...
railties/lib/rails/engine.rb
浏览文件 @
dede40ec
...
...
@@ -559,6 +559,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
: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
)
...
...
@@ -607,12 +613,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
:prepend_helpers_path
do
|
app
|
if
!
isolated?
||
(
app
==
self
)
app
.
config
.
helpers_paths
.
unshift
(
*
paths
[
"app/helpers"
].
existent
)
...
...
railties/test/application/configuration_test.rb
浏览文件 @
dede40ec
...
...
@@ -1751,6 +1751,31 @@ 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录