2016-07-28 22 views

回答

2

这就是所谓的路线通配并在Routing guide's section on route globbing解释:

路线通配符是指定一个特定的参数应匹配的路由的所有剩余部分的一种方式。例如:

get 'photos/*other', to: 'photos#unknown' 

这条路线将匹配photos/12/photos/long/path/to/12,设置params[:other]到 “12” 或 “长/路径/到/ 12”。以星号为前缀的片段称为“通配符片段”。

通配符段可以发生在路由的任何地方。例如:

get 'books/*section/:title', to: 'books#show'