Forum: Ruby on Rails Last Resort Route...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nick S. (Guest)
on 2006-02-17 22:05
(Received via mailing list)
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
Francois B. (Guest)
on 2006-02-17 22:11
(Received via mailing list)
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 !
Nick S. (Guest)
on 2006-02-17 22:21
(Received via mailing list)
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
This topic is locked and can not be replied to.