Created
June 13, 2017 10:43
-
-
Save billhorsman/1f116e8c926f109c51bd24fb17e60887 to your computer and use it in GitHub Desktop.
Handling ActionController::UnknownFormat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
# Rather than return a 500 (internal server error) let's just say we can't | |
# find what they are looking for. Typically, this is when someone hits one | |
# of our valid routes but asks for the .xml format or something. | |
rescue_from ActionController::UnknownFormat, with: :raise_unknown_format | |
def raise_unknown_format | |
render plain: 'Unknown Format', status: :not_found | |
end | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment