没有路由匹配“/ users / sign_out”当我登录时。我只是按照ryan bates教程来设计工作。我的佣金路线看起来像这样。
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"}
root /(.:format) {:controller=>"welcome", :action=>"index"}
提前致谢。
答案 0 :(得分:4)
路线看起来正确。您的退出链接应如下所示:
<%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
答案 1 :(得分:0)
我认为其他答案解决了你的问题。如果您想知道原因,请查看this setup guide中有关rails 3.1 with devise的部分。基本上,当您尝试HTTP GET注销路由时,它不存在,因为它仅为HTTP DELETE设置。您可以在问题中粘贴的路线的第二列中看到此信息。
可能是你的链接丢失了:method => :delete
同样在该教程中,您可以看到如何设置设计以在测试模式下使用GET方法。更改/config/initializers/devise.rb如下:
# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = Rails.env.test? ? :get : :delete