Skip to content

Commit

Permalink
CODEBASE-251: Using add/remove folder creates extraneous flash messag…
Browse files Browse the repository at this point in the history
…e on next page loaded.

Discarding flash messages on xhr (see http://www.whatcodecraves.com/articles/2008/12/13/rails_flash_with_ajax/ )
  • Loading branch information
Chris Beer committed Nov 2, 2010
1 parent d961e70 commit 4d9290f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ApplicationController < ActionController::Base
before_filter :default_html_head # add JS/stylesheet stuff
filter_parameter_logging :password, :password_confirmation
helper_method :current_user_session, :current_user
after_filter :discard_flash_if_xhr

def user_class; User; end

Expand Down Expand Up @@ -96,6 +97,10 @@ def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.user
end

def discard_flash_if_xhr
flash.discard if request.xhr?
end

end

0 comments on commit 4d9290f

Please sign in to comment.