I\'m using devise
sign_in
and sign_up
urls are working
but,
when I try the url: http://localhost:3000/users/sign_out
it gene
The reason for the error is that the route is inaccessible using the GET HTTP method. Notice what the relevant line looks like in your rake routes
output:
destroy_user_session DELETE /users/sign_out(.:format)
Meaning that, if you want to log the user out, you need to send a DELETE request to that url. In rails, you can generate a link that does that like so:
link_to 'Sign out', destroy_user_session_path, :method => :delete
# alternatively (although NOT recommended):
link_to 'Sign out', '/users/sign_out', :method => :delete
The important part is :method => :delete
. Note that a DELETE request is not really supported by browsers, rails is actually POSTing the data, but it sends a special parameter that simulates the DELETE method.
The reason behind this is that the "sign out" url is one that would log the current user out, a destructive action. If it was freely accessible through the browser, it could cause various problems. GET requests should never change the state of the server. For more information on this, here's a nice wikipedia article: http://en.wikipedia.org/wiki/REST#RESTful_web_services