2017-02-28 1 views
0

저는 Micheal Hartl의 튜토리얼을 진행하는 ROR 초보자입니다. 나는 튜토리얼의 모든 단계를 따르고 나는 경로에 관한 오류가 붙어있다. 나는 모든 코드를 검토하고 Google의 모든 솔루션을 사용해 보았습니다. 긴 이야기 짧은 나는 시험 통과를 얻으려고 노력하고있다. 여기 라우팅 오류 경로 일치 {: action => "/", : controller => "static_pages"}

은 여기 내 routes.rb

Rails.application.routes.draw do 
root 'static_pages#home' 
get '/help', to: 'static_pages#help' 
end` 

내 레이크 노선이


root GET/         static_pages#home
help GET /help(.:format)     static_pages#help
about GET /about(.:format)     static_pages#about
contact GET /contact(.:format)     static_pages#contact

처럼 보이는 방법은 다음과

1)Error
StaticPagesControllerTest#test_should_get_home: ActionController::UrlGenerationError: No route matches {:action=>"/", :controller=>"static_pages"} test/controllers/static_pages_controller_test.rb:10: in block in class:StaticPagesControllerTest'
2) Error
StaticPagesControllerTest#test_should_get_help: ActionController::UrlGenerationError: No route matches {:action=>"/help", :controller=>"static_pages"} test/controllers/static_pages_controller_test.rb:16:in `block in class:StaticPagesControllerTest'

내가 시도 된 오류 (설명)입니다

root 'static_pages#home' 
get '/static_pages/help', to: 'static_pages#help' 

또는

root 'static_pages#home' 
match '/help', :to => 'static_pages#help', via: [:get] 

아직 난 여전히 문제를 해결할 수 없습니다. 나는이 코드를 꼼짝 않고 며칠 동안보고 있었다. 도와주세요.

* 편집 테스트

test "should get home" do 
    get root_path 
    assert_response :success 
    assert_select "title", "Home | #{@base_title}" 
end 

test "should get help" do 
    get help_path 
    assert_response :success 
    assert_select "title", "Help | #{@base_title}" 
end 
+0

rails -v 4.1.10; ruby -v 2.1.5p273 – Yoda

+1

첫 번째 오류는'{: action => "/", : controller => "static_pages"}'를 읽습니다. 액션 (즉, 컨트롤러에 정의 된 * 메소드 *)이'/'인지 확인하십시오. 당신의 행동이 '집'과 '도움'이라고 생각됩니다. 테스트를 게시하면 더 많은 정보를 얻을 수 있습니다. –

+0

시험 추가됨, Greg – Yoda

답변

-1

나는이 책을 읽고 운동을했을 포함합니다. 내 routes.rb 파일 root_path은/static_pages/가정에 연결하고 help_path/도움말로 연결됩니다,이

root 'static_pages#home' 

get '/help', to: 'static_pages#help' 

이 방법처럼 보인다.

routes.rb이 정상적으로 작동하는지 확인하십시오. 사용 중인지 확인하십시오. rails 5

+0

이것은 OP가 이미 그의 질문에 따라 무엇을 가지고 있습니다. – jeffdill2