Hello all,
First off, I greatly apologize if this email appears more than once on
the list. I tried sending the first time about 10 hours ago, then
about 2 hours ago. It still hasn''t appeared on the list. This is my
last try. I don''t know where it''s going, but apparently gmail
is
sending it somewhere or something else is going on?
I just started learning rails last Friday and I think I''ve made some
pretty good advancements in understanding Ruby/Rails. However I''ve
run into an issue for which I cannot find the answer.
I''ve been searching for a way to catch Routing errors. Here''s
what
I''m doing (trying to do)
in routes.rb (what I added)
map.connect '''', :controller => ''site'',
:action => ''index''
map.connect '':client_name/'', :controller =>
''site'', :action => ''index''
map.connect '':client_name/:controller/:action''
the site controller defines the actions and redirects for the client:
def index
redirect_to(:client_name => site.subdomain, :controller =>
''home'', :action => ''index'')
end
this ends up with a pretty url of the type: www.mysite.com/client1/home/index
everything is looking good, but I want to be able to catch routing
errors and redirect them to the home page or show a nice 404 message
redirect_to(:client_name => Site.find(1).subdomain, :controller =>
''home'', :action = ''index'')
But what I get when i type in a bogus url such as
www.mysite.com/asdf/fs is the following:
Routing Error
No route for path: "asdf/fs"
Failure reasons:
1. <ActionController::Routing::Route "" when
{:controller=>"site",
:action=>"index"}> failed because unused components were left:
asdf/fs
2. <ActionController::Routing::Route ":client_name" when
{:controller=>"site", :action=>"index"}> failed
because unused
components were left: fs
3. <ActionController::Routing::Route
":client_name/:controller/:action" ||
{:action=>"index"}> failed
because no controller found at subpath fs
4. <ActionController::Routing::Route ":controller/service.wsdl"
when {:action=>"wsdl"}> failed because no controller found at
subpath
asdf/fs
5. <ActionController::Routing::Route ":controller/:action/:id" ||
{:id=>nil, :action=>"index"}> failed because no controller
found at
subpath asdf/fs
I don''t know how to catch this and perform the redirect.
Am I doing something really stupid here?
Any pointers would be greatly appreciated.
Thanks in advance,
andy
--
Andrew Stone