Sha256: 3c6a08825302906d9b0bae6db144108b78cf4bd59168d52110cf428a8dffceeb

Contents?: true

Size: 860 Bytes

Versions: 6

Compression:

Stored size: 860 Bytes

Contents

module Avo
  class ApplicationController < ActionController::Base
    rescue_from ActiveRecord::RecordInvalid, with: :exception_logger
    protect_from_forgery with: :exception
    before_action :init_app

    def init_app
      Avo::App.init
    end

    def exception_logger(exception)
      respond_to do |format|
        format.html { raise exception }
        format.json { render json: {
          errors: exception.record.present? ? exception.record.errors : [],
          message: exception.message,
          traces: exception.backtrace,
        }, status: ActionDispatch::ExceptionWrapper.status_code_for_exception(exception.class.name) }
      end
    end

    private
      def resource_model
        avo_resource.model
      end

      def avo_resource
        App.get_resource params[:resource_name].to_s.camelize.singularize
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
avo-0.2.5 app/controllers/avo/application_controller.rb
avo-0.2.4 app/controllers/avo/application_controller.rb
avo-0.2.3 app/controllers/avo/application_controller.rb
avo-0.2.2 app/controllers/avo/application_controller.rb
avo-0.2.1 app/controllers/avo/application_controller.rb
avo-0.2.0 app/controllers/avo/application_controller.rb