Rails routing with a parameter that contains a period

In earlier versions of Rails, you may have a parameter that includes a period (something usually reserved for its separation in format), for example:

map.connect 'c/:domain.:format', :controller=>'home', :action=>'click_credit', :requirements => { :domain => %r([^/;,?]+) }

(good tutorial here )

However, in more modern versions of Rails (2.3.x), I see that this does not succeed - the domain intercepts everything, and: the format is empty when the request arrives for /c/amazon.com.html

Any ideas on how to change it?

Thanks Tom

+3
source share
2 answers

Upgrading to rails 3 should solve your problem. I tried your route in rails 3 and it worked fine (with a little change to use the new routing syntax):

match 'c/:domain.:format', 
      :controller=>'home', 
      :action=>'click_credit', 
      :domain => %r([^/;,?]+)
# 'c/amazon.com.html' => domain: amazon.com , format: html

3 , . Per , , :requirements . , :

map.connect 'c/:domain.:format', 
            :controller=>'home', 
            :action=>'click_credit', 
            :domain => %r([^/;,?]+)
+3

slug [] [slash].

, . , .

, .

-1

Source: https://habr.com/ru/post/1781570/


All Articles