在URL中没有控制器的Rails中路由(Routing in Rails without controller in URL)
我有一个足球相关的网站,并希望将以下URL映射到相应的控制器操作。
# URL Controller Action /:country/:competition_name => "competitions#index" /teams/:country/:team_name => "teams#index"您会注意到第一个URL在URL中没有控制器名称。 如何将此URL与相应的控制器操作相匹配?
I have a soccer related website and want to map the following URLs to the corresponding controller actions.
# URL Controller Action /:country/:competition_name => "competitions#index" /teams/:country/:team_name => "teams#index"You'll notice that the first URL does not have the controller name inside the URL. How do I match this URL to the corresponding controller action?
最满意答案
尝试:
get '/:country/:competition_name/' => "competitions#index"更多信息: http : //edgeguides.rubyonrails.org/routing.html
try:
get '/:country/:competition_name/' => "competitions#index"more info here: http://edgeguides.rubyonrails.org/routing.html
更多推荐
发布评论