Skip to content

Instantly share code, notes, and snippets.

@gunn
Created February 7, 2010 11:49
Show Gist options
  • Save gunn/297389 to your computer and use it in GitHub Desktop.
Save gunn/297389 to your computer and use it in GitHub Desktop.
# 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