Forum: Ruby on Rails Route Regex Requirement not working properly

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Myron (Guest)
on 2007-06-12 12:43
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?

on 2007-06-13 18:36
(Received via mailing list)

map.admissions 'admissions/downloads', controller => 'admissions'

before you define the stuff you just defined.

This topic is locked and can not be replied to.