Is there a way to perform different routing in Rails’ routes.rb depending on whether the request URL has a trailing slash? This seems difficult since the request object has its trailing slash removed, meaning a GET of http://www.example.com/about/ has a request.url value of http://www.example.com/about. That behavior prevents matching using request-based constraints as well as route-globbing.
Is there a way to perform different routing in Rails’ routes.rb depending on whether
Share
One solution I’ve found is to use request.env[“REQUEST_URI”], which contains the raw URL submitted with the request. Unfortunately, since it’s not a direct string property of the request, it requires a custom matching object:
That seems like overkill, so hopefully someone has a more elegant approach.