【发布时间】:2014-10-16 11:25:04
【问题描述】:
使用 rails 4.1.4
我正在发送帖子请求:
curl -X POST -H "Accept:application/json" -H "Content-Type:application/json" -H "Cache-Control:no-cache" -H "Postman-Token:872ae843-bc12-8194-5984-ab2534fa9872" -d '{
"car" : {
"car_brand" : 1,
"car_model" : 1,
"car_version" : 1,
"name" : "first car"
}
}' http://0.0.0.0:3000/api/car_groups/1/cars
我的路线中的端点:
resources :car_groups, only: :none do
resources :cars, only: [:index, :show, :create, :update, :destroy]
end
这是我的服务器看到的:
在 url 中传递的参数按原样列在参数中。
在发送带有空正文的请求时,当我检查参数时,答案看起来是一样的:
> {"action"=>"create", "controller"=>"api/v1/cars", "car_group_id"=>"1", "car"=>{}, "format"=>"json", "auth_token"=>nil}
我可能缺少什么?
【问题讨论】:
标签: ruby-on-rails api rest ruby-on-rails-4.1