when record not found
suggest changeRescue from a record-not-found error instead of showing an exception or a white page. redirect_to path, 404 does not do this: a 404 is not followed as a redirect.
class ApplicationController < ActionController::Base
# ... your other stuff here
rescue_from ActiveRecord::RecordNotFound do |_exception|
render file: Rails.root.join("public/404.html"), status: :not_found, layout: false
end
end
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents