문제

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