Module: EmberRailsFlash::FlashInHeader
- Defined in:
- lib/ember-rails-flash/flash_in_header.rb
Overview
include this in your top-level controller (ApplicationController)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(controller) ⇒ Object
4 5 6 7 |
# File 'lib/ember-rails-flash/flash_in_header.rb', line 4 def self.included(controller) raise(ArgumentError, "#{self} must be included in a controller") unless controller.respond_to?(:after_filter) controller.after_filter :add_flash_to_header_if_xhr end |
Instance Method Details
#add_flash_to_header_if_xhr ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/ember-rails-flash/flash_in_header.rb', line 9 def add_flash_to_header_if_xhr if request.xhr? flash.each do |severity, | response.headers["X-Flash-#{severity.to_s.classify}"] = end # make sure flash does not appear on the next page flash.discard end end |