[英]No route matches for devise sessions destroy path
I have installed devise to my rails app and was originally able to sign out using <%= link_to('Logout', destroy_user_session_path) %>
我已经将
<%= link_to('Logout', destroy_user_session_path) %>
安装到我的Rails应用程序中,并且最初能够使用<%= 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. 但是,在添加更多代码和一些gem(回形针,act_as_votable,social_share_button)之后,我无法使用相同的链接。 When I click the link_to I receive the error
当我单击link_to时收到错误
No route matches [GET] "/users/sign_out" 没有路由匹配[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. 我也尝试将
config.sign_out_via = :get
添加到我的devise.rb文件中,但仍然遇到相同的错误。 What have I done wrong? 我做错了什么?
routes.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
sessions controller 会话控制器
class Users::SessionsController < Devise::SessionsController
def new
super
end
def create
super
end
def destroy
super
end
end
我相信<%= link_to 'Logout', destroy_user_session_path, method: :delete %>
是您要寻找的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.