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!

有帮助吗?

解决方案

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?' } %>

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top