destroy_user_session 在 Devise 中不起作用
我使用的是 Rails 3.1.3 和 devise 1.5.3,当我将 destroy_user_session_path
添加到布局文件时,链接不起作用。我可以很好地登录,但是当我单击此路径时,我收到此错误:
No route matches [GET] "/users/sign_out"
但是,如果我运行 rake 路由,我会看到列出的此路由:
destroy_user_session DELETE /users/sign_out(.:format)
{:action=>"destroy", :controller=>"devise/sessions"}
因此该路由显然使用了 DELETE 动词。我可以通过添加 :method => 来获取工作路径:delete
,但为什么我必须这样做呢?路由已经存在并且已配置为删除,那么怎么回事?
I'm using rails 3.1.3 and devise 1.5.3 and when I add destroy_user_session_path
to my layout file, the link doesn't work. I can login just fine, but when I click this path I get this error:
No route matches [GET] "/users/sign_out"
BUT, if I run rake routes, I see this route listed:
destroy_user_session DELETE /users/sign_out(.:format)
{:action=>"destroy", :controller=>"devise/sessions"}
So the route clearly uses the DELETE verb. I can get the path to work by adding :method => :delete
, but why do I have to do that? The route is there and configured to be a delete already, so what's up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
rake paths
显示您的应用程序将响应哪些路由。您需要确保生成与服务器期望的链接相匹配的链接。link_to
不会根据路由检查允许使用哪些动词 - 它希望您提供正确的动词。rake routes
shows you what routes your application will respond to. It's up to you to make sure that you generate links that match what the server expects.link_to
does not check to see which verbs are allowed according to the routes - it expects you to supply the correct verb.