简单的问题,但不知何故,答案让我望而却步。
在使用 Zeitwerk 迁移到 Rails 6 时,我得到:
Please, check the "Autoloading and Reloading Constants" guide for solutions.
(called from <top (required)> at APP_ROOT/config/environment.rb:7)
rails aborted!
Zeitwerk::NameError: wrong constant name Enforce-calls-to-come-from-aws inferred by Module from directory
APP_ROOT/app/junkyard/enforce-calls-to-come-from-aws
Possible ways to address this:
* Tell Zeitwerk to ignore this particular directory.
* Tell Zeitwerk to ignore one of its parent directories.
* Rename the directory to comply with the naming conventions.
Run Code Online (Sandbox Code Playgroud)
这看起来很棒:这是一个垃圾文件夹,永远不应加载,因此忽略它是完全有道理的。
https://github.com/fxn/zeitwerk 上的 Zeitwerk 文档说
tests = "#{__dir__}/**/*_test.rb"
loader.ignore(tests)
loader.setup …Run Code Online (Sandbox Code Playgroud)