Rescuing ActiveRecord RecordNotFound with redirect to
suggest changeYou can rescue a RecordNotFound exception with a redirect instead of showing an error page:
class ApplicationController < ActionController::Base
# your other stuff
rescue_from ActiveRecord::RecordNotFound do |exception|
redirect_to root_path, 404, alert: I18n.t("errors.record_not_found")
end
end
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents