When I try to sign out i am getting error of No route matches [GET] "/users/sign_out". this is my link tag for Signout.
当我试图签名时,我的错误是没有路线匹配[GET]“/用户/sign_out”。这是我的注册链接标签。
<%= link_to "Sign Out", destroy_user_session_path, method: :get , class: "nav-link" %>
Here is what my routes related to my User model and Devise look like:
以下是我与我的用户模型和设计相关的路线:
Rails.application.routes.draw do
devise_for :users do
get '/users/sign_out' => 'devise/sessions#destroy'
end
root 'books#index'
resources :books do
member do
put "like", to: "books#upvote"
end
end
end
And this is my devise.rb
这是我的诡计
config.sign_out_via = :get
4 个解决方案
#1
3
Try the following in routes.rb
按以下步骤做
devise_for :users
devise_scope :user do
get '/users/sign_out' => 'devise/sessions#destroy'
end
for more information how to by devise
欲知更多如何设计
#2
1
If you intend to keep the default route path for signout /users/sign_out
, then instead of doing this:
如果您打算保留签出/用户/sign_out的默认路由路径,那么不要这样做:
devise_for :users do
get '/users/sign_out' => 'devise/sessions#destroy'
end
The way it should be handled is one of two ways:
应对它的方式有两种:
-
Use DELETE method instead of GET
使用DELETE方法代替GET
<%= link_to "Sign Out", destroy_user_session_path, method: :delete, class: "nav-link" %>
<%= link_to "Sign Out",驱逐舰_user_session_path, method::delete, class: "nav-link" %>
-OR-
或者,
-
Edit your devise.rb initializer and change
编辑你的设计。rb初始化和改变
config.sign_out_via = :delete
toconfig.sign_out_via = :get
配置。sign_out_via =:delete to config。sign_out_via =:
#3
0
Make sure of this:
确保:
in your Gemfile include
在你Gemfile包括
gem 'jquery-rails'
in application.js
在application.js
//= require jquery
//= require jquery_ujs
In my opinion is not so good change the routers or the method to sign out, this action should be done always with DELETE. That worked for me.
在我看来并不是很好的换路由器或签出方法,这个动作应该总是用删除来做。为我工作。
#4
0
Since you are destroying the session, it is not a :get
method but a :delete
. Modify the link to:
由于正在销毁会话,所以它不是:get方法,而是:delete。修改的链接:
= link_to "Log out", destroy_user_session_path, method: :delete
= link_to "Log out",驱逐舰_user_session_path, method: delete
#1
3
Try the following in routes.rb
按以下步骤做
devise_for :users
devise_scope :user do
get '/users/sign_out' => 'devise/sessions#destroy'
end
for more information how to by devise
欲知更多如何设计
#2
1
If you intend to keep the default route path for signout /users/sign_out
, then instead of doing this:
如果您打算保留签出/用户/sign_out的默认路由路径,那么不要这样做:
devise_for :users do
get '/users/sign_out' => 'devise/sessions#destroy'
end
The way it should be handled is one of two ways:
应对它的方式有两种:
-
Use DELETE method instead of GET
使用DELETE方法代替GET
<%= link_to "Sign Out", destroy_user_session_path, method: :delete, class: "nav-link" %>
<%= link_to "Sign Out",驱逐舰_user_session_path, method::delete, class: "nav-link" %>
-OR-
或者,
-
Edit your devise.rb initializer and change
编辑你的设计。rb初始化和改变
config.sign_out_via = :delete
toconfig.sign_out_via = :get
配置。sign_out_via =:delete to config。sign_out_via =:
#3
0
Make sure of this:
确保:
in your Gemfile include
在你Gemfile包括
gem 'jquery-rails'
in application.js
在application.js
//= require jquery
//= require jquery_ujs
In my opinion is not so good change the routers or the method to sign out, this action should be done always with DELETE. That worked for me.
在我看来并不是很好的换路由器或签出方法,这个动作应该总是用删除来做。为我工作。
#4
0
Since you are destroying the session, it is not a :get
method but a :delete
. Modify the link to:
由于正在销毁会话,所以它不是:get方法,而是:delete。修改的链接:
= link_to "Log out", destroy_user_session_path, method: :delete
= link_to "Log out",驱逐舰_user_session_path, method: delete