开发者

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开发者_C百科 " + 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?


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?


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜