destroy_user_session 在 Devise 中不起作用

发布于 2024-12-28 04:27:25 字数 483 浏览 3 评论 0原文

我使用的是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

破晓 2025-01-04 04:27:25

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文