2013-08-27 67 views
0

的routes.rb軌道轉換路徑例如

match "about/how_it_works" => "about#how_it_works", :as => "about_how_it_works", :via => :get 
    match "about/we_are" => "about#we_are", :as => "about_we_are", :via => :get 
    match "about/what_is" => "about#what_is", :as => "about_what_is", :via => :get 

我讀this rails guide,改變了我的代碼。

的routes.rb

scope(path_names: { about_we_are: 'translated-about-we-are', about_what_is: 'translated-about-what-is' }) do 
    resources :about, path: 'translated-about' 
end 

但是,當我輸入localhost:3000 /約/翻譯 - 約-WE-是,我沒有遇到路由匹配error.Do你知道如何與這個處理問題?

回答

0

既然您已指定path資源about您的路徑將變爲translated-about/...。所以你需要使用:

http://localhost:3000/translated-about/translated-about-we-are 

然後你不應該得到錯誤。

您可以從應用程序目錄中檢查通過發出rake routes生成的所有路由。