when record not found

suggest change

Rescue 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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents