2015-04-30 96 views
0

我沿着Michael Hartl Rails tutorial chapter 8關於身份驗證,我遇到了一個錯誤。在清單8.28中,我們將代碼添加到我們的集成測試中以測試註銷用戶。這涉及發送'刪除'HTTP請求。運行此測試後,結果應爲綠色,但遇到以下錯誤:Rails測試中的HTTP請求'刪除'

ERROR["test_login_with_valid_information_followed_by_logout", UsersLoginTest, 2015-04-15 03:20:30 +0000] test_login_with_valid_information_followed_by_logout#UsersLoginTest (1429068030.89s) AbstractController::ActionNotFound:
AbstractController::ActionNotFound: The action 'delete' could not be found for SessionsController test/integration/users_login_test.rb:28:in block in <class:UsersLoginTest>' test/integration/users_login_test.rb:28:in block in '

我一直無法找到任何有關此問題的信息。有沒有人有任何想法是什麼造成這種情況?爲了記錄,我正在使用教程中Michael Hartl推薦的Cloud 9 IDE。根據要求

路線文件:

Rails.application.routes.draw do 
    root    'static_pages#home' 
    get 'help' =>  'static_pages#help' 
    get 'about' => 'static_pages#about' 
    get 'contact' => 'static_pages#contact' 
    get 'signup' => 'users#new' 
    get 'login' => 'sessions#new' 
    post 'login' => 'sessions#create' 
    delete 'logout' =>'sessions#delete' 
    resources :users 
end 
+1

請把你的路由文件 – crispychicken

+0

謝謝,這確實是其中的錯誤了! –

回答

0

路線:

delete 'logout' =>'sessions#delete' 

應該是:

delete 'logout' =>'sessions#destroy'