Rails & Devise: destroy_user_session_path going to Users#Show?

Pretty standard link:

<li><%= link_to 'Log Out', destroy_user_session_path(current_user) %></li>

rake routes:

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

routes.rb:

  devise_for :users, :controllers => { omniauth_callbacks: "users/omniauth_callbacks", sessions: "users/sessions" }

users/sessions_controller.rb:

class Users::SessionsController < Devise::SessionsController

  def destroy
    binding.pry
    cookies.delete(:auth_token)
    flash[:notice] = "Successfully Logged Out"
    redirect_to new_session_path
  end

end

binding.pry is not even being called. The link takes me to the url /users/sign_out but the view is Users#show.

Any ideas?

Answers


The destroy action requires the DELETE HTTP verb as shown in your rake routes output.

You need to add method: :delete to the end of your link helper, otherwise the link will produce a GET request.


Need Your Help

Getting CFMutableDictionaryRef Values

objective-c cocoa macos nsmutabledictionary

I would like to access some values from a CFMutableDictionaryRef and then do some math on them. Using the code below I have managed to print some properties of my battery. I am also able to print out

CSS comments layout

html css

I want to make a CSS layout for comments.