Question

Noob here building my first Rails 4.0 app using Devise. Set up my controller and routes using the standard Devise tactics.

Rake Routes shows:

destroy_user_session DELETE /users/sign_out(.:format)   devise/sessions#destroy

In my Nav, my code is:

<%= link_to "Sign Out", destroy_user_session_path, method: :destroy, data: { confirm: 'Are you sure?' } %>

I'm running the Guard gem so my server is always on, so I know it's not a mismatch b/w my routes and the server. I still get the following error:

No route matches [POST] "/users/sign_out"

Any suggestions? Thanks all!

Was it helpful?

Solution

You probably need to change the method (http verb) option to delete:

<%= link_to "Sign Out", destroy_user_session_path, method: :delete, data: { confirm: 'Are you sure?' } %>

OTHER TIPS

Check in config/initializers/devise.rb and make sure this is set:

config.sign_out_via = :delete

Also, in the view I have this and works just fine:

<%= link_to 'Logout', destroy_user_session_path, :method=>'delete' %>

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