在我的 restful 网络服务中路由删除不工作

Routing to delete in my restful web service is not working

我在路由到我的 restful Web 服务上的删除方法以获得权限时遇到问题。 我的路线设置如下:

  namespace :service do
      namespace :v1 do
        resources :surveys do
          resources :permissions, only: [:index, :create, :delete, :update]
        end
      end
    end

以下规范通过

   it "routes toya expected controller method" do
      {:get => 'service/v1/surveys/3/permissions'}.should route_to(controller: 'service/v1/permissions', action: 'index', :survey_id => "3")
   end

此规范不合格

describe 'DELETE :destroy' do
    it "routes to expected controller method" do
      {:delete => 'service/v1/surveys/3/permissions'}.should route_to(controller: 'service/v1/permissions', action: 'destroy', :survey_id => "3")
    end
  end

我的控制器的代码片段如下

module Service
  module V1
    class PermissionsController < ApplicationController

      before_filter :authenticate_user!, :only => []

      def index
        render :json => permissions,  :each_serializer => Service::V1::PermissionSerializer
      end

 def destroy
            debugger
            # cant route to here 
            a = 1
      end

    end
  end
end

有什么建议吗?我对销毁和删除有点困惑,我想这可能是我问题的根源

您还需要传递权限 ID,例如:-

{:delete => 'service/v1/surveys/3/permissions/permission_id'}.should route_to(controller: 'service/v1/permissions', action: 'destroy', :survey_id => "3", :id => "permission_id")