rails: Can no longer rescue_from ActionController::RoutingError
Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/4444 Created by Luigi Montanez - 2011-02-14 05:42:01 UTC
In Rails 2.3.x, one is able to stick this in ApplicationController to present the user with a custom 404 screen:
rescue_from(ActionController::RoutingError) { render :text => 'This is a custom 404.' }
Now in Rails 3, because routing is done as middleware (ActionDispatch), it seems that the ActionController::RoutingError that gets thrown by ActionDispatch no longer can be caught from ApplicationController – the error is already thrown and ActionDispatch renders /templates/rescues/routing_error.erb before the controller can rescue_from the error.
About this issue
- Original URL
- State: closed
- Created 13 years ago
- Comments: 58 (15 by maintainers)
Links to this issue
Commits related to this issue
- Make rails app available to catch RoutingError (raised by ActionDispatch) Ref: https://github.com/rails/rails/issues/671 — committed to fameandpartners/website by sfate 7 years ago
- Make rails app available to catch RoutingError (raised by ActionDispatch) Ref: https://github.com/rails/rails/issues/671 — committed to fameandpartners/website by sfate 7 years ago
- Make rails app available to catch RoutingError (raised by ActionDispatch) Ref: https://github.com/rails/rails/issues/671 — committed to fameandpartners/website by sfate 7 years ago
- Make rails app available to catch RoutingError (raised by ActionDispatch) Ref: https://github.com/rails/rails/issues/671 — committed to fameandpartners/website by sfate 7 years ago
- Make rails app available to catch RoutingError (raised by ActionDispatch) Ref: https://github.com/rails/rails/issues/671 — committed to fameandpartners/website by sfate 7 years ago
- [Feature] [WEBSITE-1239] 404 page redesign (#2253) * 404 page redesign * Fix css format * Fix link destination * Remove old 404 file * Add new controller and helper * Add new 404 templ... — committed to fameandpartners/website by albertocorrea 7 years ago
- [Feature] [WEBSITE-1239] 404 page redesign (#2253) * 404 page redesign * Fix css format * Fix link destination * Remove old 404 file * Add new controller and helper * Add new 404 templ... — committed to fameandpartners/website by albertocorrea 7 years ago
For those that are using gems that have their own routes: you can also add the catch-all route after initialize to account for that. Just put something like this in application.rb: