2013-08-27 61 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生成的所有路由。