Commit 4954b22b authored by marcheing's avatar marcheing

Rescue from ActiveRecord::NotFound errors by rendering the 404 page

parent bca58fbf
......@@ -5,6 +5,8 @@ class ApplicationController < ActionController::Base
before_action :configure_devise_parameters, if: :devise_controller?
before_action :set_locale
rescue_from ActiveRecord::RecordNotFound, with: :render_404
protected
# We don't have a way to test this unless we have the Devise controllers among our code.
......@@ -29,4 +31,10 @@ class ApplicationController < ActionController::Base
def default_url_options(options = {})
{ locale: I18n.locale }.merge options
end
private
def render_404
render file: File.join(Rails.root, 'public', '404.html'), layout: false, status: 404
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment