Module: PagesCore::ErrorRenderer

Extended by:
ActiveSupport::Concern
Included in:
BaseController
Defined in:
app/controllers/concerns/pages_core/error_renderer.rb

Instance Method Summary collapse

Instance Method Details

#render_error(error, options = {}) ⇒ Object

Renders a fancy error page from app/views/errors. If the error name is numeric, it will also be set as the response status. Example:

render_error 404


11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/concerns/pages_core/error_renderer.rb', line 11

def render_error(error, options = {})
  options[:status] ||= error if error.is_a? Numeric
  respond_to do |format|
    format.html do
      options[:layout] = error_layout(error, options)
      @email = current_user.try(&:email) || ""
      render({ template: "errors/#{error}" }.merge(options))
    end
    format.any { head options[:status] }
  end
  true
end