错误我试图实现与轨道4轨道4 - 无路由匹配,卷曲
当通过浏览器
http://api.myapp.dev/v1/users/1.json
访问API的JSON响应是正确的API。但是,当我尝试使用curl
curl http://api.myapp.dev/v1/users/1.json
它返回一个HTML得到JSON,但基本上误差没有路由匹配[GET]“用户/ 1”
这是我的路线文件。
Myapp::Application.routes.draw do
devise_for :users
#routes for API
constraints subdomain: 'api' do
scope module: 'api' do
namespace :v1 do
resources :users, :only => [:show]
end
end
end
end
我控制器
class Api::V1::UsersController < ApplicationController
respond_to :json
def show
respond_with User.find(params[:id])
end
end
当我运行rake routes
,路线存在:
v1_user GET /v1/users/:id(.:format) api/v1/users#show {:subdomain=>"api"}
是必要的额外的配置?
UPDATE 我使用prax作为代理服务器
在Chrome中打开你的检查,然后转到网络选项卡在从浏览器发出请求之前,转到网络选项卡。右键单击请求并选择“复制为卷曲请求”,然后尝试使用 – Brennan 2014-10-17 02:33:01
我尝试了它,但没有结果。卷曲没有任何回报。 – rogelio 2014-10-17 02:37:41
现在正在工作。我清理浏览器缓存并重新启动prax。 – rogelio 2014-10-17 03:33:52