In routes.rb I have set up
match “member/:permalink” => “accounts#profile”
when the user’s url name is john-green, john_green, johngreen, everything is working fine, but when the url name is john.green, so as the permalink is taken just the first part – john
Specifically, from the Rails debug window:
Request
Parameters:
{"permalink"=>"john",
"format"=>"green"}
Why is not accepted the . (dot) in the permalink? Exist any feature for using that?
EDIT when I use
match "member/:permalink" => "accounts#profile",
:requirements => { :permalink => /.+/ }
I get
{"requirements"=>{"permalink"=>/.+/},
"permalink"=>"john",
"format"=>"green"}
By default Rails treats everything after the dot as a format and looks like there’s no easy way of overriding this behavior. But there’s a bit dirty workaround that uses
:requirementsoption:By adding greedy regexp for the
:permalinkparameter you make Rails pass everything it finds after themember/substring in the path intoparams[:permalink].