Sha256: affef343d3e2a7790a6efd38cb403a4f1ca97dc2b8c0f6f20cc36c18a4e21566

Contents?: true

Size: 923 Bytes

Versions: 15

Compression:

Stored size: 923 Bytes

Contents

class ApplicationController < ActionController::Base
  protect_from_forgery
  respond_to :html

  # NotFound errors will be redirected to the action not_found while any other will be redirected to the action generic.
  rescue_from ApiClient::Exceptions::Unauthorized, :with => :unauthorized_access
  rescue_from ApiClient::Exceptions::NotFound, :with => :not_found
  rescue_from ApiClient::Exceptions::Generic, :with => :generic

  # This code is only for example purposes.
  # Any behavior can be executed here. Just write your own.
  def unauthorized_access
    redirect_to "http://www.example.com/sign_in?redirect_uri=#{request.url}"
  end

  def not_found
    ApplicationMailer.send_not_found_notice.deliver
    render :file => '/public/404.html', :status => 404
  end

  def generic(exception)
    ApplicationMailer.send_generic_error(exception).deliver
    render :file => '/public/404.html', :status => 404
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
api-client-3.1.0 examples/controllers/application_controller.rb
api-client-3.0.0 examples/controllers/application_controller.rb
api-client-2.7.0 examples/controllers/application_controller.rb
api-client-2.6.0 examples/controllers/application_controller.rb
api-client-2.5.0 examples/controllers/application_controller.rb
api-client-2.5.0.rc1 examples/controllers/application_controller.rb
api-client-2.4.0 examples/controllers/application_controller.rb
api-client-2.3.0 examples/controllers/application_controller.rb
api-client-2.2.0 examples/controllers/application_controller.rb
api-client-2.1.0 examples/controllers/application_controller.rb
api-client-2.0.3 examples/controllers/application_controller.rb
api-client-2.0.2 examples/controllers/application_controller.rb
api-client-2.0.1 examples/controllers/application_controller.rb
api-client-2.0.0 examples/controllers/application_controller.rb
api-client-2.0.0.rc2 examples/controllers/application_controller.rb