Sha256: 662cfdb667f42395e5d0ae7de7d9bb0428b3292e0c8b8243541157578a3bf899

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

module Tuning
  module ActionController
    module Base
      extend ActiveSupport::Concern

      protected

      def error(exception=nil)
        if exception
          logger.error exception.message
          exception.backtrace.each { |line| logger.error line }
        end
        respond_to do |format|
          format.xml { head 500 }
          format.json { head 500 }
          format.any { render file: Rails.root.join('public', '500.html'), status: 500, layout: false }
        end
      end

      def not_found
        respond_to do |format|
          format.xml { head 404 }
          format.json { head 404 }
          format.any { render file: Rails.root.join('public', '404.html'), status: 404, layout: false }
        end
      end

      def unauthorized
        respond_to do |format|
          format.xml { head 401 }
          format.json { head 401 }
          format.any { render file: Rails.root.join('public', '422.html'), status: 401, layout: false }
        end
      end

      def forbidden
        respond_to do |format|
          format.xml { head 403 }
          format.json { head 403 }
          format.any { render file: Rails.root.join('public', '422.html'), status: 403, layout: false }
        end
      end

      def unprocessable_entity
        respond_to do |format|
          format.xml { head 422 }
          format.json { head 422 }
          format.any { render file: Rails.root.join('public', '422.html'), status: 422, layout: false }
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tuning-0.3.3 lib/tuning/action_controller/base.rb
tuning-0.3.2 lib/tuning/action_controller/base.rb
tuning-0.3.0 lib/tuning/action_controller/base.rb