I'm trying to rescue from ActionController::RoutingError
and I can't get it to work. I tried almost everything that I could find online, including rescue_from ActionController::RoutingError in Rails 4. I have an errors controller and error pages. I got to work cancan access denied
and RecordNotFound
, but I can solve the RoutingError
.
For cancan I use this inside application_controller.rb
rescue_from CanCan::AccessDenied do
render template: 'errors/error_403', status: 403
end
and I have this in my routes:
match "/404", to: "errors#error_404", via: :all
If I do the same thing for RoutingError
it won't work.
I've also tried match '*path', :to => "errors#error_404"
but I get erors.
How can I solve this?
Edit: If I do the same thing for RoutingError
as for access denied:
rescue_from ActionController::RoutingError do
render template: 'errors/error_404', status: 404
end
it won't work.