在URL中没有控制器的Rails中路由(Routing in Rails without controller in URL)

编程入门 行业动态 更新时间:2024-10-25 06:29:38
在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

更多推荐

本文发布于:2023-08-01 17:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1361564.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   控制器   URL   Rails   controller

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!