Albzi
Albzi

Reputation: 15609

Changing route from GET to Delete in RoR

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

This is the route I am interested in.

However, when I go to /logout, I get this error:

No route matches [DELETE] "/logout", how do I change this route from get to delete?

This is how my route is currently set up:

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

and my link:

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

Upvotes: 0

Views: 160

Answers (1)

Zelardiel
Zelardiel

Reputation: 74

Change:

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

to:

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

You can find more information on routing on this page: Routing Rails Guide

Upvotes: 5

Related Questions