views:

26

answers:

2

This is a follow up to link text about trying to remove the stack trace for routing errors out of my log, and to handle bad routes a little better. Here's my relevant routes.rb entry and controller

map.default '*', :controller => 'error', :action => 'route_not_found'

class ErrorsController < ApplicationController

  def route_not_found
    logger.error("routing error for " + request.url)
  end

end

I also tried map.connect, as that was recommended in a related thread, but that didn't work either. Does the named route 'map.default' have a special meaning?

+1  A: 

There are some articles about how to render custom rails error pages: http://www.perfectline.co.uk/blog/custom-dynamic-error-pages-in-ruby-on-rails

See also: http://stackoverflow.com/questions/2238244/custom-error-pages-in-rails

Note that those errors are shown in production mode only (by default).

giraff
+3  A: 

map.connect '*path', :controller => 'error', :action => 'route_not_found' as the very last route should work as you expect (see here under 'Route Globbing'). If you hit that route what is happening? Also, have you restarted your server when changing routes?

thenduks
Yes, I had been restarting my server after changing routes. Your route appears to work, in that it appears to be at least hitting the ErrorsController. But it's throwing another error `NameError (uninitialized constant ErrorController)` I think I've seen this before but can't remember what could be causing it.
Ah that's just because I copied your code and modified it. You want: `:controller => 'errors'` with the _s_! :)
thenduks
That did it, thanks very much for the prompt responses. I wondered about the singular/plural matching between the route and controller earlier, but wasn't sure if that was the issue or another syntax issue was the problem.
Yea that's burned me before too. Generally the rule is that whatever you typed to generate the controller is what you put in the route.
thenduks