After upgrading my RoR app to 6.0, I'm getting this error:
NameError: uninitialized constant Sites::NetworkResolver::ExternalApi
. This is my app/resolvers/sites/network_resolver.rb
file:
module Sites
class NetworkResolver
ExternalApi::Graphql
...
end
end
and my app/services/external_api/graphql.rb
module ExternalApi
module Graphql
...
end
end
in the app/services
folder, I have a settings file with the same name external_api.rb
module ExternalApi
...
end
rails zeitwerk:check
rails aborted!
NameError: uninitialized constant Sites::NetworkResolver::ExternalApi
If I put it at the top of app/resolvers/network_resolver.rb
file
require 'external_api/graphql'
I need to update externalApi
to externalAPI
so that Api is uppercase
app/services/external_api/graphql.rb to define constant ExternalAPI::Graphql, but didn't
so code works but didn't want to update more than 100 files
CodePudding user response:
By default, app/resolvers/network_resolver.rb
should define NetworkResolver
, rather than Sites:: NetworkResolver
, maybe the path is mistaken?
You can force inflection for external_api
to not use the acronym this way:
# config/initializers/zeitwerk.rb
Rails.autoloaders.main.inflector.inflect("external_api" => "ExternalApi")