【发布时间】:2017-02-22 14:48:45
【问题描述】:
这不是 this question 的副本,因为我没有为此资源使用自定义路由,也没有使用 slug。我正在使用 Rails 5。
这是我的路由器
namespace :api, defaults: { format: :json } do
namespace :v1 do
resources :node_categories, only: [:create, :update, :destroy]
resources :edge_categories, only: [:create, :update, :destroy]
resources :nodes, only: [:index, :create, :destroy] do
collection do
match '/bulk' => 'nodes#bulk', via: :post
end
end
一切似乎都很好。 rake routes 打印路线OK
api_v1_node_categories POST /api/v1/node_categories(.:format) api/v1/node_categories#create {:format=>:json}
api_v1_node_category PATCH /api/v1/node_categories/:id(.:format) api/v1/node_categories#update {:format=>:json}
PUT /api/v1/node_categories/:id(.:format) api/v1/node_categories#update {:format=>:json}
DELETE /api/v1/node_categories/:id(.:format)
控制器的命名空间很好,并且测试通过了(虽然在这个项目中没有进行路由测试)。所有其他路线似乎都可以正常工作。只有这个资源会带来麻烦。对任何操作的任何请求都会返回 404,但日志显示没有此类请求,没有错误或异常,也没有。
所有客户端应用程序、Postman 甚至 curl 的行为方式都相同,返回一个幻像 404,以及一个空响应,日志中没有记录。
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails url-routing ruby-on-rails-5