Home > Mobile >  Rails 7 Autoloading problem with active job
Rails 7 Autoloading problem with active job

Time:02-26

I have an app directory in my Rails 7 App, app/beer, and in that folder a file named cool.rb with a defined method execute.

So in an ActiveJob DrinkSudsJob perform method I am calling a method execute from cool.rb as:

def perform
  Beer::Cool.execute
end

But my App blows up. Tells me unitialized constant DrinkSudsJob::Beer

Zeitwerk:check tells me everything is fine. What am I doing wrong here?

bin/rails r 'puts ActiveSupport::Dependencies.autoload_paths'
/Users/sputz/Documents/Workspace/Apps/2022/fug/app/beer

CodePudding user response:

If zeitwerk:check passes and app/beer is in the autoload paths, then app/beer/cool.rb defines (and has to define) Cool, not Beer::Cool.

  • Related