Routes in Ruby on Rails are case sensitive. It seems someone brought this up before, and it has been labeled will not fix.
http://rails.lighthouseapp.com/projects/8994/tickets/393-routes-are-case-sensitive
That strikes me as unfortunate, as I don't really see any upside on my own application for routes to be case sensitive, while on the downside it creates a potential for confusion and a general appearance of lack of polish in my opinion.
What's the best way to make my routes case insensitive?
I found this tip on a Google search:
map.connect "web_feeds/:action", :controller => 'web_feeds', :action => /[a-z_]+/i
This is clever, but it still leaves the web_feeds portion of the url case sensitive. I don't see any similar way around this, however, without entering in each possible combination of wEb_feEds manually, but that is obviously a horrible solution for any number of reasons.
on Jul 27, 2020. The standard is that the path in a URL is case-sensitive.
Text matching is case-insensitive and based on the decoded representation of the URL's path.
The Rails router is responsible for redirecting incoming requests to controller actions. The routing module provides URL rewriting in native Ruby. It recognizes URLs and dispatches them as defined in config/routes.
Routes in Rails are case sensitive because URLs are case sensitive. From the W3C:
URLs in general are case-sensitive (with the exception of machine names). There may be URLs, or parts of URLs, where case doesn't matter, but identifying these may not be easy. Users should always consider that URLs are case-sensitive.
I've just has the same problem, and solved it using middleware - have a look here:
http://gehling.dk/2010/02/how-to-make-rails-routing-case-insensitive/
Note: This only applies for Rails 2.3+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With