0
votes

I have installed devise to my rails app and was originally able to sign out using <%= link_to('Logout', destroy_user_session_path) %>

However, somewhere along the line after adding more code and a few gems (paperclip, act_as_votable, social_share_button) I was not able to use the same link. When I click the link_to I receive the error

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

I have also tried adding config.sign_out_via = :get to my devise.rb file but still got the same error. What have I done wrong?

routes.rb

    Rails.application.routes.draw do

  devise_for :users, controllers: { registrations: 'users/registrations', sessions: 'users/sessions' }


  root to:'ideas#index'

  get  "/page", to: 'pages#index'

  resources :ideas, only: [:index, :show, :create, :destroy, :new] do
    member do
      put "like", to: "ideas#upvote"
      put "dislike", to: "ideas#downvote"
    end
  end

  resources :comments, only: [:create]
end

sessions controller

    class Users::SessionsController < Devise::SessionsController

  def new
    super
  end


  def create
    super
  end


  def destroy
    super
  end



end
1
Tried both of those and no dice. I have ' <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>' in my application.html.erb and changing it to <%= javascript_include_tag :default %> errors out as well.James Chou

1 Answers

1
votes

I believe <%= link_to 'Logout', destroy_user_session_path, method: :delete %> is what you're looking for