Routing Errors are caught if somebody is calling a path on your app which is not existing. This how I handled it. I just added this line to the end of the routes.rb
match '*path', :to => 'page#routing_error'
It is important that this is on the bottom of the routes.rb. That just means, if no other route matches than handle that by the PageController and the routing_error Action. That can look like this:
class PageController < ApplicationController def routing_error p "routing error path: #{params[:path]}" redirect_to "/" end end
If you want to still see the error message in development, add this to you render_not_found method:
if Rails.application.config.consider_all_requests_local
raise ActionController::RoutingError.new(‘Not Found’)
end
That’s helpful. Thank your for your input.
Although this is a very common approach to catch missing routes, certain routes which are generated by gems. Putting a route which catches all such routes which are not present at the end of the route might also interfere with those routes.