Question

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 %>

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top