在RoR中将路由从GET更改为Delete

时间:2013-07-16 13:42:18

标签: ruby-on-rails routes custom-routes

logout GET /logout(.:format) devise/sessions#destroy

这是我感兴趣的路线。

但是,当我进入/注销时,我收到此错误:

No route matches [DELETE] "/logout",如何将此路线从get更改为delete

这就是我目前的路线设置方式:

get 'logout', to: 'devise/sessions#destroy', as: :logout

和我的链接:

<%= link_to "Sign Out", logout_path, method: :delete %>

1 个答案:

答案 0 :(得分:5)

变化:

get 'logout', to: 'devise/sessions#destroy', as: :logout

为:

delete 'logout', to: 'devise/sessions#destroy', as: :logout

您可以在此页面上找到有关路由的更多信息:Routing Rails Guide