我正在自动重新加载API及其子目录:
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
我的app/api/test_api.rb
module TestApi
class API < Grape::API
format :json
default_format :json
formatter :json, Grape::Formatter::Jbuilder
mount TestApi::API::V1
class V1 < Grape::API
version ['v2', 'v1'], using: :path
mount TestApi::API::V1::Scenario
mount TestApi::API::V1::Tags
end
end
我的app / api / v1 / scenario.rb
module TestApi
class API < Grape::API
class V1 < Grape::API
class Scenario < Grape::API
helpers ParamsHelper
end
end
end
end
但是,当我启动rails服务器时,它失败并显示Unable to autoload constant Scenario, expected /Users/bpopa/projects/test/app/api/v1/scenario.rb to define it (LoadError)
我在这里做什么错了?