2011-10-09 34 views
0

的routes.rb =>Ruby on Rails的設計http://0.0.0.0:3000/users/sign_out獲取路由錯誤

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"} 

當i型軌道服務器每次我=>

/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] "https://stackoverflow.com/users/sign_out" 

我該怎麼辦才能解決這個問題?

回答

5

請注意您的路線說/ users/sign_out是一個DELETE請求。大多數瀏覽器默認不會發出DELETE請求。只要進入該網址即可獲得/ users/sign_out的GET請求。

how to add sign out links應該幫助你得到它的工作。

+0

謝謝,這有效,但我該如何擺脫此消息? /home/user1/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53:警告:已初始化常量WFKV – shibly

+0

我認爲與這個問題無關。 – ryantm

+0

是的,這可能是無關的,但我該如何解決它?我應該爲此開始一個新線程嗎? – shibly

3

:method => :delete添加到您的登出鏈接。