Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 1e6befe

Browse files
Capture requests without explicit format
1 parent eba3b06 commit 1e6befe

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

app/controllers/application_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
class ApplicationController < ActionController::Base
22
protect_from_forgery with: :exception
33

4+
# Exceptions
45
rescue_from ActionController::InvalidAuthenticityToken, with: :render_422
6+
rescue_from ActionView::MissingTemplate, with: :render_204
57

68
# API access
79
before_action :authenticate_with_token!, if: :api_request
@@ -58,6 +60,10 @@ def handle_unverified_request
5860
raise(ActionController::InvalidAuthenticityToken)
5961
end
6062

63+
def render_204
64+
render status: 422, json: { message: "No Content" }
65+
end
66+
6167
def render_422
6268
redirect_to '/422'
6369
end

0 commit comments

Comments
 (0)