Reputation: 263
How to rescue from RoutingError
in Rails 3.2 applications such as redirecting to root_path
?
Upvotes: 0
Views: 1411
Reputation: 9700
I can think of no circumstances when you would want to rescue from a RoutingError.
If you want all routes not otherwise specified to redirect to some particular action (for custom 'not found' errors, for instance), you can make the last route in your routes.rb
file match anything and point there:
match "*path" => 'some_controller#some_action'
Routes are tried in order and the first one which matches is used, so as long as this remains last, it will be used if and only if no other route matches the requested path.
Upvotes: 1