我可以为下面两行写一行路线吗?
match "/article/:id/" => "articles#redirect"
match "/articles/:id/" => "articles#redirect"
我试过像
这样的东西 match "/:article_redirect/:id/" => "articles#redirect", :constraints => {:article_redirect => /[article|articles]/}
但它不起作用。
答案 0 :(得分:1)
我认为你的正则表达不好:试试
match "/:article_redirect/:id/" => "articles#redirect", :constraints => {:article_redirect => /(article|articles)/}
是(article|articles)
而不是[article|articles]