Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View flash.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# 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
Something went wrong with that request. Please try again.