2017-02-22 48 views
0

这不是this question的重复,因为我没有使用此资源的自定义路由,也没有slu。。我使用Rails 5.资源路径存在但Rails抛出404

这是我的路由器

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,但日志不会显示这样的请求,没有错误或异常,而不是任何内容。

所有客户端应用程序,邮差甚至curl行为方式都相同,返回幻影404以及空响应,但在日志中没有记录。

任何想法?

回答

0

测试

scope '/api' do 
    scope '/v1' do 
     ... 
    end 
end 

取而代之的命名空间,我用我的API。

0

该错误原来与Fabio(我的路由器)路由权限有关。新的路线需要被允许。

它与Rails无关。