Class: ErrorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/errors_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_navable, #current_navable=, #current_user, #point_navigation_to, #redirect_www_subdomain, #set_locale

Instance Method Details

#showObject

General Exception Handling: Show Message on Error Page


railscasts.com/episodes/53-handling-exceptions-revised



10
11
12
13
14
15
16
# File 'app/controllers/errors_controller.rb', line 10

def show
  @exception = env["action_dispatch.exception"]
  respond_to do |format|
    format.html #{ render action: request.path[1..-1] }
    format.json { render json: {status: request.path[1..-1], error: (@exception.message || "Zeitüberschreitung (Timeout).")} }
  end
end

#unauthorizedObject

Unauthorized Error: Redirect to Login Page




21
22
23
24
25
# File 'app/controllers/errors_controller.rb', line 21

def unauthorized
  if not current_user
    redirect_to , flash: { error: I18n.t(:unauthorized_please_sign_in) }
  end
end