Current versions of better_errors already do this automatically.
If you use the Better Errors gem Show archive.org snapshot , you will sometimes notice that it can be very slow. This is because it sometimes renders a huge amount of data that will actually be hard to render for your browser.
You can significantly improve performance by adding this to config/initializers/better_errors
:
if defined?(BetterErrors) && Rails.env.development?
module BetterErrorsHugeInspectWarning
def inspect_value(obj)
inspected = obj.inspect
if inspected.size > 20_000
inspected = "Object was too large to inspect (#{inspected.size} bytes). "
end
CGI.escapeHTML(inspected)
rescue NoMethodError
"<span class='unsupported'>(object doesn't support inspect)</span>"
rescue Exception
"<span class='unsupported'>(exception was raised in inspect)</span>"
end
end
BetterErrors.ignored_instance_variables += [ :@_request, :@_assigns, :@_controller, :@view_renderer ]
BetterErrors::ErrorPage.prepend(BetterErrorsHugeInspectWarning)
end
(credits to GitHub user bquorning)
Posted by Tobias Kraze to makandra dev (2017-06-26 11:00)