1

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!

Ajay Gopalan
  • 103
  • 1
  • 1
  • 5

2 Answers2

1

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?' } %>
markets
  • 6,709
  • 1
  • 38
  • 48
  • In that case, you should accept the answer, upvote is also useful for the community. You're welcome! – markets Apr 11 '14 at 00:40
0

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

thecrentist
  • 1,241
  • 2
  • 19
  • 28