Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails 5,路由声明但未找到_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails Rails 5,路由声明但未找到

Ruby on rails Rails 5,路由声明但未找到,ruby-on-rails,ruby,Ruby On Rails,Ruby,在我的路线配置中,我有: constraints subdomain: 'api' do scope module: 'api' do namespace :v1 do get '/me', to: 'users#me' end end end 料仓/耙道返回 v1_me GET /v1/me(.:format) api/v1/users#me {:subdomain=>"api"} 当我尝试uri或

在我的路线配置中,我有:

constraints subdomain: 'api' do
    scope module: 'api' do
        namespace :v1 do
            get '/me', to: 'users#me'
        end
    end
end
料仓/耙道返回

v1_me GET    /v1/me(.:format)     api/v1/users#me {:subdomain=>"api"}
当我尝试uri或使用postman时,我有一个404NotFound错误

 ActionController::RoutingError (No route matches [GET] "/v1/me"):

我的代码怎么了?

您为子域设置了约束。 因此,您必须通过类似
api.localhost:3000
这对于任何开发环境来说都不是现成的

路由确保指定的端点仅为
api
子域定义

你可以试试这些:

http://api.lvh.me:3000

http://api.localhost:3000


您可能需要在主机文件中添加条目,以将任何自定义域指向
127.0.0.1

您为子域设置了约束。 因此,您必须通过类似
api.localhost:3000
这对于任何开发环境来说都不是现成的

路由确保指定的端点仅为
api
子域定义

你可以试试这些:

http://api.lvh.me:3000

http://api.localhost:3000


您可能需要在主机文件中添加条目,以将任何自定义域指向
127.0.0.1

您可以使用子域访问本地主机,如下所示
http://api.lvh.me:3000/


因此,您的URL变为
http://api.lvh.me:3000/api/v1/me

您可以使用子域访问本地主机,如下所示
http://api.lvh.me:3000/

因此,您的URL变为
http://api.lvh.me:3000/api/v1/me