开发者

RoutingError Page 404

开发者 https://www.devze.com 2023-02-03 12:21 出处:网络
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?

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

精彩评论

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

关注公众号