我正在从classic
自动装弹器切换到zeitwerk
。我遇到过这样的问题:
NameError: uninitialized constant SomeHelper::Forms
我有一个辅助模块SomeHelper
在app/helpers/some_helper.rb
包含这个代码
module SomeHelper
extend Forms::DateTimePickerHelper
...rest code....
Forms::DateTimePickerHelper
模块位于app/helpers/forms/date_time_picker_helper.rb
我的问题是:如何纠正文件结构或模块名称,使Zeitwerk好?
找到原因,在config/application.rb
中添加了这些行
config.autoload_paths << Rails.root.join('app/helpers')
config.autoload_paths << Rails.root.join('app/helpers/forms')
删除它们解决了问题。希望这对大家有所帮助!