Sha256: 875870740cab5270675a1888263243203943c216526f6e11283f0f71a24d49e5

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require 'application_responder'

class ApplicationController < ActionController::Base
  include BasicAuthentication

  rescue_from Exception, with: :server_error if Rails.env.production? or Rails.env.staging?
  rescue_from ActiveRecord::RecordNotFound, with: :page_not_found if Rails.env.production? or Rails.env.staging?
  rescue_from ActionController::RoutingError, with: :page_not_found if Rails.env.production? or Rails.env.staging?

  self.responder = ApplicationResponder
  respond_to :html, :json

  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  before_filter :set_audit_user
  protect_from_forgery with: :exception

  def server_error(exception)
    Rollbar.error "ApplicationController#server_error --exception: #{exception}"
    render template: 'errors/internal_server_error', status: 500
  end

  def page_not_found
    render template: 'errors/not_found', status: 404
  end

  protected

  def set_user_time_zone
    Time.zone = current_user.time_zone if student_signed_in? && current_student.time_zone.present?
  end

  def devise_parameter_sanitizer
    if resource_class == User
      User::ParameterSanitizer.new(User, :user, params)
    else
      super # Use the default one
    end
  end

  private

  def set_audit_user
    # Set audit current user
    Audited.current_user_method = :current_user
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cybele-1.9.1 templates/app/controllers/application_controller.rb.erb
cybele-1.9.0 templates/app/controllers/application_controller.rb.erb