联合两条相似的路线

时间:2016-04-15 08:11:00

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-4

我有两条路线:

  get "shopping", to: "bar#show"
  get "shopping/*relative_path", to: "bar#show"

我如何加入他们,到一条路线?

当我只是省略get "shopping", to: "bar#show"时,转到localhost:3000/shopping的用户不会被重定向到控制器bar#show

感谢

1 个答案:

答案 0 :(得分:2)

您可以将第二部分包装成括号:

get "shopping(/*relative_path)", to: "bar#show"

docs中此行为的说明。