Sha256: 855b40172e838876e89f79bef2f202d5beb5d0d3ab519502892817e436b9f536

Contents?: true

Size: 924 Bytes

Versions: 5

Compression:

Stored size: 924 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

5 entries across 5 versions & 1 rubygems

Version Path
api-client-2.0.0.rc1 examples/controllers/application_controller.rb
api-client-1.10.0 examples/controllers/application_controller.rb
api-client-1.9.1 examples/controllers/application_controller.rb
api-client-1.9.0 examples/controllers/application_controller.rb
api-client-1.8.2 examples/controllers/application_controller.rb