我将所有控制器声明为
class Api::V1::SomeController < Api::V1::ApiController; (...); end
在哪里
class Api::V1::ApiController < ApplicationController; end
我所有的控制器都放在/app/controllers/api/v1/*_controller.rb
,ApplicationController
下app/controllers/application_controller.rb
。
在开发中一切正常,但我在生产中要求和加载包装在 api 版本控制命名空间中的控制器时遇到问题。
在生产环境(本地或heroku)中,我得到了:LoadError (Unable to autoload constant Api::V1::SomeController, expected /app/app/controllers/api/v1/some_controller.rb to define it):
app/config/environments/production.rb
在生产环境中配置和要求版本控制 api的正确方法是什么。