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 =>
DownloadableFileCategory.category_regex}

And here’s the method definition for
DownloadableFileCategory.category_regex:

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

Regexp.new(regex_str.chop, Regexp::IGNORECASE)

end

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?

Thanks,
Myron

try

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

before you define the stuff you just defined.

-L