Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# actionpack/lib/action_controller/rescue.rb
module ActionController
class Base
# Attempts to render a static localized error page based on the <tt>status_code</tt>
# thrown, or just return headers if no such files exists. For example, if a 500 error
# is being handled Rails will first attempt to render the file based on the current
# locale such as <tt>public/</tt>. If it does not exist, attempts to
# render <tt>public/500.html</tt>. If the files doesn't exist, the body of the response
# will be left empty.
def render_optional_error_file(status_code)
status = interpret_status(status_code)
locale_path = "#{Rails.public_path}/#{status[0,3]}.#{I18n.locale}.html" if I18n.locale
path = "#{Rails.public_path}/#{status[0,3]}.html"
if locale_path && File.exist?(locale_path)
render :file => locale_path, :status => status, :content_type => Mime::HTML
elsif File.exist?(path)
render :file => path, :status => status, :content_type => Mime::HTML
head status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.