I'm attempting to upgrade from Rails 5 to 6. I did the upgrade steps including adding this:
# config/application.rb
config.load_defaults 6.0
I have this class:
# lib/notification/auto_thank.rb
module Notification
class AutoThank
def perform
# stuff
end
end
end
Which is used in a task:
namespace :notify do
task auto_thank: :environment do
Notification::AutoThank.new.perform
end
end
When I do puts config.autoload_paths
, it's listed, so I expect it to autoload:
/my/app/path/lib/notification/auto_thank.rb
But when I run the task I get an error:
NameError: uninitialized constant Notification
It gets stranger. When I add a require to the task:
task auto_thank: :environment do
require '/my/app/path/lib/notification/auto_thank.rb'
Notification::AutoThank.new.perform
end
I get a different error:
NameError: expected file /my/app/path/lib/notification/auto_thank.rb to define constant AutoThank, but didn't
What am I missing?