尝试访问以下URL时,出现404错误页面:
然而,我的routes.rb文件中提到了这个路由确实存在:dev.mydomain.com/api
routes.rb
constraints :subdomain => 'dev' do
root :to => 'developers/main#index', :as => :developers
namespace 'api', :as => :developers_api do
root :to => 'developers/apidoc/main#index'
end
end
rake routes
developers /(.:format) {:subdomain=>"dev", :controller=>"developers/main", :action=>"index"}
developers_api_root /api(.:format) {:subdomain=>"dev", :controller=>"api/developers/apidoc/main", :action=>"index"}
controller
/app/controllers/developers/apidoc/main_controller.rb
class Developers::Apidoc::MainController < Developers::BaseController
def index
end
end
日志
[router]: GET dev.mydomain.com/api dyno=web.1 queue=0 wait=0ms service=14ms status=404 bytes=0
[web.1]: Started GET "/api"
[web.1]: ActionController::RoutingError (uninitialized constant Api::Developers)