Route Regex Requirement not working properly

I’m trying to get my routes to work properly. Here’s how I’m defining
one of my routes:

map.downloads ‘:category/downloads’, :controller => ‘downloads’, :action
=> ‘list_downloads_for_category’, :requirements => {:category =>

And here’s the method definition for

def self.category_regex
regex_str = “”
for category in DownloadableFileCategory.find(:all)
regex_str += category.category.downcase
regex_str += “|”
end, Regexp::IGNORECASE)


This creates a regex such as /admissions|jobs/i so that the url
/admissions/downloads maps to the list_downloads_for_category method
with params[:category] = “admissions” and /jobs/downloads maps to the
same method with params[:category] = “jobs”. That part works correctly.

The part that’s not working is the Regexp::IGNORECASE option. URLS such
as “/Admissions/downloads”, “/ADMISSIONS/downloads” do not match this
route even though I’ve set the regex to ignore case. I tried testing
just the regex in script/console and it worked just fine. It just
doesn’t work when trying to match the URL.

Why doesn’t this work?



map.admissions ‘admissions/downloads’, controller => ‘admissions’

before you define the stuff you just defined.