Created
January 10, 2012 21:20
-
-
Save gosuri/1591273 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# May not be the best approach | |
# Issues with Proxies limititing headers | |
# Headers could be cached | |
# Not sure of having JSON | |
class ApplicationController < ActionController::Base | |
after_filter :flash_to_headers | |
def flash_to_headers | |
return unless request.xhr? | |
unless flash.empty? | |
response.headers['X-Flash'] = flash.to_json | |
end | |
flash.discard # don't want the flash to appear when you reload page | |
end | |
=begin | |
# js | |
$(document).ajaxError(function(event, request) { | |
var flash = request.getResponseHeader('X-Flash'); | |
// Do something | |
}); | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment