使用CURL或POSTMAN客户端
时,找不到我的以下API路由 function measurementsCtrl() {
var vm = this;
vm.options = {
chart: {
type: 'lineChart',
height: 450,
margin : {
top: 20,
right: 20,
bottom: 40,
left: 55
},
x: function(d){ return d.x; },
y: function(d){ return d.y; },
xAxis: {
axisLabel: 'Time (ms)'
},
yAxis: {
axisLabel: 'Voltage (v)',
tickFormat: function(d){
return d3.format('.02f')(d);
},
axisLabelDistance: -10
},
callback: function(chart){
console.log("!!! lineChart callback !!!");
}
}
}
但是当我运行Started POST "/api/users/register_handheld" for 181.74.100.34 at 2017-05-11 11:27:42 +0000
DEBUG: Chewy strategies stack: [2] <- atomic @ /home/deploy/boold/shared/bundle/ruby/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
ActionController::RoutingError (No route matches [POST] "/api/users/register_handheld"):
时,此网址就会出现。
rake routes
如果我点击rails console,这个URL确实有效:
api_users_register_handheld POST /api/users/register_handheld(.:format)
crowd/api/v1/handheld_users#create {:format=>"json"}
路由文件是
app.post "/api/users/register_handheld"
Started POST "/api/users/register_handheld" for 127.0.0.1 at 2017-05-11 11:21:03 +0000
DEBUG: Chewy strategies stack: [3] <- atomic @ /home/deploy/boold/shared/bundle/ruby/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
Processing by Crowd::Api::V1::HandheldUsersController#create as JSON
注意:此repo是Rails Engine
答案 0 :(得分:0)
尝试以下代码:
/api/users/register_handheld.json
指定格式类型json
答案 1 :(得分:0)
也许这可以帮助某人。
使用POSTMAN时,我不小心取消选中Host
键入标头(POSTMAN每次发送任何请求都会自动生成它)。直到我将自己的请求与类似请求进行比较并找到丢失的密钥,这才是问题的噩梦。