It's a part of nested resources:

resources :repos, path: '/', only: [], param: :name, constraints: { repo_name: /.+/ } do

It should accept dots (because of added constraints), but it doesn't (No route matches...). I have also tried another regexps like /\d.+/ , /.*/ or /[^/]+/ - the result is same.

What else can cause the problem?

Application is written with Rails 4.

有帮助吗?

解决方案 2

I have resolved the problem my myself.

My mistake was not to looking carefully enough on rake routes. In 3rd level of nested routes one of element was member element, and one was resource. The name of parameters were different - for member element it was just a "name", where for resource it is "repo_name". In constraints I was setting it for "repo_name" - so the "name" was not accepting the dots.

A bit automagical thing is that when I changed the constraints from { repo_name: /.+/ } to { name: /.+/ }, the both the name and repo_name parameters are accepting the dots.

其他提示

Try tweaking the constraint to this, it should allow anything but a slash:

constraints: { repo_name: /[^\/]+/ }

It looks like you were on the right track with one of the earlier regexes you tried, but forgot to escape the slash (unless you mistyped it)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top