Error_page
ref https://rubyplus.com/articles/4061-How-to-handle-exceptions-in-Rails-5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| # route.rb
match "*path", to: "page#catch_404", via: :all
# application_controller.rb
rescue_from ActionController::RoutingError do |exception|
logger.error 'Routing error occurred'
render plain: '404 Not found', status: 404
end
# page_controller.rb
def catch_404
raise ActionController::RoutingError.new(params[:path])
end
|