Sha256: 54a5bc5bf75f7cd888c44fca671253a4a01243b3dc7065423a91c804d74aad2a

Contents?: true

Size: 467 Bytes

Versions: 5

Compression:

Stored size: 467 Bytes

Contents

module Alchemy
  class API::BaseController < Alchemy::BaseController
    layout false
    respond_to :json

    rescue_from CanCan::AccessDenied,         with: :render_not_authorized
    rescue_from ActiveRecord::RecordNotFound, with: :render_not_found

    private

    def render_not_authorized
      render json: {error: 'Not authorized'}, status: 403
    end

    def render_not_found
      render json: {error: 'Record not found'}, status: 404
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alchemy_cms-3.1.0.beta5 app/controllers/alchemy/api/base_controller.rb
alchemy_cms-3.1.0.beta4 app/controllers/alchemy/api/base_controller.rb
alchemy_cms-3.1.0.beta3 app/controllers/alchemy/api/base_controller.rb
alchemy_cms-3.1.0.beta2 app/controllers/alchemy/api/base_controller.rb
alchemy_cms-3.1.0.beta1 app/controllers/alchemy/api/base_controller.rb