设计路由错误:没有路由匹配[GET]“/users/sign_out"; [英] Devise routing error: No route matches [GET] "/users/sign_out"
本文介绍了设计路由错误:没有路由匹配[GET]“/users/sign_out";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
routes.rb =>
routes.rb =>
devise_for :users
resources :posts
match "posts/:id/categ" => "posts#categ"
match "posts/:id/tag_posts" => "posts#tag_posts"
match "posts/searcharchive" => "posts#searcharchive"
#post "posts/searcharchive"
resources :categories
resources :comments
resources :countpages
耙路线 =>
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET /users/cancel(.:format) {:action=>"cancel", :controller=>"devise/registrations"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"}
posts GET /posts(.:format) {:action=>"index", :controller=>"posts"}
POST /posts(.:format) {:action=>"create", :controller=>"posts"}
new_post GET /posts/new(.:format) {:action=>"new", :controller=>"posts"}
edit_post GET /posts/:id/edit(.:format) {:action=>"edit", :controller=>"posts"}
post GET /posts/:id(.:format) {:action=>"show", :controller=>"posts"}
PUT /posts/:id(.:format) {:action=>"update", :controller=>"posts"}
DELETE /posts/:id(.:format) {:action=>"destroy", :controller=>"posts"}
/posts/:id/categ(.:format) {:controller=>"posts", :action=>"categ"}
/posts/:id/tag_posts(.:format) {:controller=>"posts", :action=>"tag_posts"}
posts_searcharchive /posts/searcharchive(.:format) {:controller=>"posts", :action=>"searcharchive"}
categories GET /categories(.:format) {:action=>"index", :controller=>"categories"}
POST /categories(.:format) {:action=>"create", :controller=>"categories"}
new_category GET /categories/new(.:format) {:action=>"new", :controller=>"categories"}
edit_category GET /categories/:id/edit(.:format) {:action=>"edit", :controller=>"categories"}
category GET /categories/:id(.:format) {:action=>"show", :controller=>"categories"}
PUT /categories/:id(.:format) {:action=>"update", :controller=>"categories"}
DELETE /categories/:id(.:format) {:action=>"destroy", :controller=>"categories"}
comments GET /comments(.:format) {:action=>"index", :controller=>"comments"}
POST /comments(.:format) {:action=>"create", :controller=>"comments"}
new_comment GET /comments/new(.:format) {:action=>"new", :controller=>"comments"}
edit_comment GET /comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"}
comment GET /comments/:id(.:format) {:action=>"show", :controller=>"comments"}
PUT /comments/:id(.:format) {:action=>"update", :controller=>"comments"}
DELETE /comments/:id(.:format) {:action=>"destroy", :controller=>"comments"}
countpages GET /countpages(.:format) {:action=>"index", :controller=>"countpages"}
POST /countpages(.:format) {:action=>"create", :controller=>"countpages"}
new_countpage GET /countpages/new(.:format) {:action=>"new", :controller=>"countpages"}
edit_countpage GET /countpages/:id/edit(.:format) {:action=>"edit", :controller=>"countpages"}
countpage GET /countpages/:id(.:format) {:action=>"show", :controller=>"countpages"}
PUT /countpages/:id(.:format) {:action=>"update", :controller=>"countpages"}
DELETE /countpages/:id(.:format) {:action=>"destroy", :controller=>"countpages"}
root / {:controller=>"posts", :action=>"index"}
链接 =>
<% if user_signed_in? %>
<%= link_to('Logout', destroy_user_session_path, :method => 'delete') %>
<%= link_to 'Add Post', :controller=>'/posts', :action=>'new' %>
<%= link_to 'Add Category', :controller=>'/categories', :action=>'new' %>
<%= link_to 'Display ategories', :controller=>'/categories', :action=>'index' %>
<% else %>
<%= link_to('Login', new_user_session_path) %>
<% end %>
http://0.0.0.0:3000/users/sign_out
=>
错误=>
Routing Error
No route matches [GET] "/users/sign_out"
我该怎么办?
推荐答案
您正在使用 GET 调用该路由,而根据其定义,该路由需要 DELETE.
You are calling the route using GET while the route requires DELETE, according to its definition.
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
链接正确使用了 DELETE
The link correctly uses DELETE
<%= link_to('Logout', destroy_user_session_path, :method => 'delete') %>
您是否尝试直接在浏览器中访问该 URL?在这种情况下,它不起作用.您需要单击带有 DELETE 方法的链接.
Did you try to visit the URL directly in your browser? In this case, it won't work. You need to click on a link with the DELETE method.
这篇关于设计路由错误:没有路由匹配[GET]“/users/sign_out";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文