I'm trying to match a URL something like
http://example.com/this.is.my.full.hostname/something/else
apparently when I pass the param in the routes.rb file it doesn't recognize this parameter
my code says the following
match '/:computer_hostname/somethingelse' => 'test#info'
any ideas what's the right 开发者_JS百科way to achieve the URL I wanted above ? Or is it even possible ? I know period is allowed character in URL but does it allow more than one ?
I think the constraints
method/option will help you out. Try something like the following:
match ':hostname/something/else' => 'test#info',
:constraints => {:hostname => /[A-Za-z0-9\._\-]+/}
If you're doing multiple matches all with the same :hostname
segment, then you can wrap them in a constraints method call:
constraints(:hostname => /[A-Za-z0-9\._\-]+/) do
match ':hostname/something/else' => 'test#info'
match ':hostname/foo/bar' => 'test#foo'
end
精彩评论