I am including a concern in a controller:
# app/controllers/api/v2/base_controller.rb
class API::V2::BaseController < ActionController::Base
include UserApiAccessRecorder
end
# app/controllers/concerns/user_api_access_recorder.rb
module UserApiAccessRecorder
extend ActiveSupport::Concern
included do
# xxx
end
end
These code works normally before. And after upgrading to rails 7, i got the following error:
NameError - uninitialized constant API::V2::BaseController::UserApiAccessRecorder:
app/controllers/api/v2/base_controller.rb:9:in `<class:BaseController>'
The namespace info of UserApiAccessRecorder in the above error message is also wrong, as UserApiAccessRecorder is in the top namespace. I've no idea about how to track this issue. As i know, all modules & class in app dir are autoloaded, so this error should not occur.
uninitialized constant API::V2::BaseController::UserApiAccessRecorderis telling you is the current module nesting at the point where you referenced the missing constant and not where it looked for the constant.API::V2::BaseController] since you're declaring the namespaces wrong before going up to main. You also have an inconsistency in the naming in that you have the correct inflexion forAPIbut not forUserApiAccessRecorderbut that more just something that makes my eyelid twitch.