Search code examples
ruby-on-railsroutescase-sensitivecase-insensitive

Rails Routes - How to make them case insensitive?


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.


Solution

  • 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+

    • Carsten