Last Resort Route


#1

Hey all, can’t find the answer to this through the powers of Google.
How can I get a “catch-all” route for anything that doesn’t get mapped
otherwise.

So basically, the idea I want is to have something like:

map.connect “*”, :controller => “page”, :action => “redirect”

and call it good. I’ve tried overriding a couple of methods, but there
has to be a way to set this up. (none of my overriding trickery
worked)

My main problem is that I’ll have urls that will go any number of
“/”'s deep, so its hard to configure/type all these in obviously.

Any help is appreciated!
-Nick


#2

Hello Nick !

2006/2/17, Nick S. removed_email_address@domain.invalid:

map.connect “*”, :controller => “page”, :action => “redirect”

and call it good. I’ve tried overriding a couple of methods, but there
has to be a way to set this up. (none of my overriding trickery
worked)

My main problem is that I’ll have urls that will go any number of
“/”'s deep, so its hard to configure/type all these in obviously.

I think you’re on the right track. Try this:

map.connect ‘*route’, :controller => ‘page’, :action => ‘redirect’

In PageController#redirect, you will have access to params[:route],
and it will be an Array. Run with this, and tell us how it worked.

Hope that helps !


#3

Sweet! Worked like a charm. I dont really actually care about the
route results as I’m just looking at the URI info passed in through
the request params. Either way, she works now!

Thanks!
-Nick