开发者

RoutingError Page 404

I have an exception ActionController::RoutingError when the us开发者_运维百科er tries to access a non existing route. How can I redirect the user to the 404.html page or render an error on that page?

e.g: when I try to access https://github.com/someuser I get a 404 page on that URL.

I've tried this in application controller with no success:

rescue_from ActionController::RoutingError do |exception|
  render '/public/404.html'
end


This is a known problem. You should have a look at the comments posted there, especially this one by Jose Valim.

Edit: This seems to be a better solution, and compatible with other Rack middlewares.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜