1

I'm in process of switching from classic autoloader to zeitwerk. And I've faced this problem:

NameError: uninitialized constant SomeHelper::Forms

I have a helper module SomeHelper in app/helpers/some_helper.rb which contains this code

module SomeHelper
  extend Forms::DateTimePickerHelper
    ...rest code....

The Forms::DateTimePickerHelper module is located in app/helpers/forms/date_time_picker_helper.rb

My question is: how to correct the file structure or module names to make Zeitwerk good?

A. Askarov
  • 625
  • 7
  • 13

1 Answers1

1

Found the cause, in config/application.rb these lines were added

config.autoload_paths << Rails.root.join('app/helpers')
config.autoload_paths << Rails.root.join('app/helpers/forms')

removing them solved the issue. Hope this helps someone!

A. Askarov
  • 625
  • 7
  • 13
  • 3
    This code was never actually needed. In both Zeitwerk and Classic every subdirectory of app is an autoloading root so it would look for the constant in `app/**/forms/some_helper.rb` anyways. – max Apr 05 '23 at 14:16