没有路由匹配设计会话销毁路径

时间:2017-09-20 02:40:50

标签: ruby-on-rails ruby devise routes

我已经安装了我的rails应用程序,并且最初能够使用<%= link_to('Logout', destroy_user_session_path) %>

注销

然而,在添加更多代码和一些宝石(paperclip,act_as_votable,social_share_button)之后的某个地方,我无法使用相同的链接。当我点击link_to时收到错误

没有路线匹配[GET]“/ users / sign_out”

我还尝试将config.sign_out_via = :get添加到我的devise.rb文件中,但仍然遇到了同样的错误。我做错了什么?

的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

会话控制器

    class Users::SessionsController < Devise::SessionsController

  def new
    super
  end


  def create
    super
  end


  def destroy
    super
  end



end

1 个答案:

答案 0 :(得分:1)

我相信<%= link_to 'Logout', destroy_user_session_path, method: :delete %>正是您正在寻找的