By default, Rails 3 interprets a dot in a URL as a format specifier. For example, given the route
and the URL
/foo/bar.baz, this would result in the following parameters being passed:
This may not be what you desire, so here is a quick workaround, using segment constraints:
The constraint for the
:search parameter now matches anything but a slash, which includes the dot, and Rails will no longer interpret it as a format.
Update: The same effect can be achieved by using dynamic segments and the same regular expression, like this:
Update2: If you want to also ignore slashes within the URL, you can do the following:
With this matcher, if you’d open the URL “
/foo/los.tacos/son.deliciosos” it would result in a
search parameter with the value “
This is a small update on a blog post which I wrote back on my old blog. Still need to find a way to move all those articles over to this blog without breaking the links.