user26270
user26270

Reputation: 7084

why is this rails route not going to my controller?

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?

Upvotes: 0

Views: 349

Answers (2)

rfunduk
rfunduk

Reputation: 30452

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?

Upvotes: 3

giraff
giraff

Reputation: 4711

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: Custom Error Pages in Rails?

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

Upvotes: 1

Related Questions