1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/controllers/application_controller.rb

25 lines
523 B
Ruby
Raw Normal View History

2018-11-22 14:58:12 -05:00
# frozen_string_literal: true
2018-11-22 14:33:08 -05:00
class ApplicationController < ActionController::Base
2018-11-29 08:51:03 -05:00
class NotAuthorizedError < RuntimeError; end
skip_before_action :verify_authenticity_token, if: :json_request?
2018-11-29 08:51:03 -05:00
rescue_from ActiveRecord::RecordNotFound, with: :not_found
rescue_from NotAuthorizedError, with: :unauthorized
private
def json_request?
request.format.json?
end
2018-11-29 08:51:03 -05:00
def not_found
render status: :not_found, json: {}
end
def unauthorized
render status: :unauthorized, json: {}
end
2018-11-22 14:33:08 -05:00
end