Class: RubyCms::ErrorsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RubyCms::ErrorsController
- Defined in:
- app/controllers/ruby_cms/errors_controller.rb
Overview
Handles 404 errors from catch-all routes. Add this to the BOTTOM of your routes.rb to capture routing errors:
match "*path", to: "ruby_cms/errors#not_found", via: :all,
constraints: ->(req) { !req.path.start_with?("/rails/") }
Instance Method Summary collapse
Instance Method Details
#not_found ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/ruby_cms/errors_controller.rb', line 11 def not_found # Log the routing error to VisitorError (skips in development) RubyCms::VisitorError.log_routing_error(request) respond_to do |format| format.html do render_html_not_found end format.json { render json: { error: "Not found" }, status: :not_found } format.any { head :not_found } end end |