[英]No route matches [GET] for route with constraint
Have been No route error for a route with constraints. 对于具有约束的路线,没有路线错误。 Please find below my route code and the string I want to match it with.
请在下面找到我的路线代码和我想与之匹配的字符串。
Route: 路线:
get '/product/:product_title', to: 'frontend_pages#product' ,
constraints: { product_title: /[A-Za-z0-9-]/ }
Matching String: www.mylink.com/product/this-is-the-matching-string 匹配字符串: www.mylink.com/product/this-is-the-matching-string
Would really appreciate any help that will come my way. 真的很感谢我能提供的任何帮助。 Thanks
谢谢
Let look around constraints part in your defining route. 让我们看看定义路线中的约束部分。 Issue is at here
问题在这里
constraints: { product_title: /[A-Za-z0-9-]/ }
regular expression that you write is fail Try yourself with: 您编写的正则表达式失败。
product_title: /[A-Za-z0-9]+/
Hope this will help you. 希望这会帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.