Sha256: 24ea4af898435ca5e1d1659ba7595a1b526b22d2606c5ae70f40af383be35e09

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

module Federails
  class ApplicationController < ActionController::Base
    include Pundit::Authorization

    rescue_from ActiveRecord::RecordNotFound, with: :error_not_found

    layout Federails.configuration.app_layout if Federails.configuration.app_layout

    private

    def error_fallback(exception, fallback_message, status)
      message = exception&.message || fallback_message
      respond_to do |format|
        format.json { render json: { error: message }, status: status }
        format.html { raise exception }
      end
    end

    def error_not_found(exception = nil)
      error_fallback(exception, 'Resource not found', :not_found)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
federails-0.1.0 app/controllers/federails/application_controller.rb