문제

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