Created
February 7, 2010 11:49
-
-
Save gunn/297389 to your computer and use it in GitHub Desktop.
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
# flash / restfulx doesn't like 422 error codes. if it's fxml, return 200s instead of 422s | |
require 'rack/utils' | |
class CleanFxmlResponseMiddleware | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
status, headers, body = @app.call(env) | |
is_fxml = env["action_controller.rescue.request"].parameters["format"] == "fxml" | |
status = 200 if is_fxml && status==422 | |
[status, headers, body] | |
end | |
end | |
ActionController::Dispatcher.middleware.use CleanFxmlResponseMiddleware |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment