There is such a routing:

resources :controller, olny: :index, path: 'dir' do get '*path' => 'controller#index', on: :collection, format: false end 

In *path gets a relative path in a specific directory, which is on the fs ext4. If there is a question mark in the directory name, then everything that comes before it is in the path , and the rest is in params . I would like something like this:

 get '*path' => 'controller#index', on: :collection, format: false, params: false 

I know that I have to dig in the direction of constraints: but I don’t think how to use them.

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

No

? question mark in the URL ? separates two substantially different parts of the URL:

 схема://юзер:пароль@хост:порт/путь?строка_запроса ^ ^ 

To use ? as it is , it is necessary to shield it .

In the standard Ruby library there is a CGI.escape '?' , and it returns "%3f" . That is, a URL with a question mark in the path will look something like this:

 /name%3F/hi 
  • Thank you path.gsub('?','%3f') helps in generating links. By the way, unlike CGI.escape(path) which misleads the controller ... - Simant
  • @Simant Of course, where the escape , there is unescape . In the URI there is something like that, in my opinion. - D-side
  • @Simant path.gsub('?','%3f') is a terrible idea. In addition to question marks, there are many other characters that require escaping .-. - D-side
  • Understand. However, other characters in the url do not interfere. Probably the rail itself shields them. But the question mark is a stumbling block ... - Simant
  • @Simant may have surprises further:] - D-side