Ruby on Rails 设计 http://0.0.0.0:3000/users/sign_out 获取路由错误

发布于 2024-12-09 01:50:30 字数 2942 浏览 0 评论 0原文

路线.rb =>

Sendemail::Application.routes.draw do
    devise_for :users

    get "user/index"

    get "home/index"

    root :to => 'home#index'
end

耙子路线=>

        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"}
       user_confirmation POST   /users/confirmation(.:format)     {:action=>"create", :controller=>"devise/confirmations"}
   new_user_confirmation GET    /users/confirmation/new(.:format) {:action=>"new", :controller=>"devise/confirmations"}
                         GET    /users/confirmation(.:format)     {:action=>"show", :controller=>"devise/confirmations"}
              user_index GET    /user/index(.:format)             {:controller=>"user", :action=>"index"}
              home_index GET    /home/index(.:format)             {:controller=>"home", :action=>"index"}
                    root        /                                 {:controller=>"home", :action=>"index"}

当我输入 Rails Server 时,我每次都会收到此消息=>

/home/user1/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV

对于“http://0.0.0.0:3000/users/sign_out”

Routing Error

No route matches [GET] "/users/sign_out"

我应该做什么来解决这个问题?

routes.rb =>

Sendemail::Application.routes.draw do
    devise_for :users

    get "user/index"

    get "home/index"

    root :to => 'home#index'
end

rake routes =>

        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"}
       user_confirmation POST   /users/confirmation(.:format)     {:action=>"create", :controller=>"devise/confirmations"}
   new_user_confirmation GET    /users/confirmation/new(.:format) {:action=>"new", :controller=>"devise/confirmations"}
                         GET    /users/confirmation(.:format)     {:action=>"show", :controller=>"devise/confirmations"}
              user_index GET    /user/index(.:format)             {:controller=>"user", :action=>"index"}
              home_index GET    /home/index(.:format)             {:controller=>"home", :action=>"index"}
                    root        /                                 {:controller=>"home", :action=>"index"}

When i type rails server i get this message every time =>

/home/user1/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV

For "http://0.0.0.0:3000/users/sign_out"

Routing Error

No route matches [GET] "/users/sign_out"

What should i do to fix this problem ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

随风而去 2024-12-16 01:50:30

请注意您的路由如何显示 /users/sign_out 是 DELETE 请求。大多数浏览器默认不发出 DELETE 请求。只需访问该 URL 就可以向 /users/sign_out 发出 GET 请求。

这个 如何添加注销链接应该可以帮助您使其正常工作。

Notice how your routes say /users/sign_out is a DELETE request. Most browsers do not make DELETE requests by default. Just going to that URL would be a GET request to /users/sign_out.

This how to add sign out links should help you get it working.

岁吢 2024-12-16 01:50:30

添加 :method => :delete 到您的注销链接。

Add :method => :delete to your signout link.

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