Skip to content

Instantly share code, notes, and snippets.

@simonwh
Created August 27, 2013 12:22
Show Gist options
  • Save simonwh/6352826 to your computer and use it in GitHub Desktop.
Save simonwh/6352826 to your computer and use it in GitHub Desktop.
module ActionController
module Flash
extend ActiveSupport::Concern
included do
delegate :alert, :notice, :error, :success, :to => "request.flash"
helper_method :alert, :notice, :error, :success
end
protected
def redirect_to(options = {}, response_status_and_flash = {}) #:doc:
if alert = response_status_and_flash.delete(:alert)
flash[:alert] = alert
end
if notice = response_status_and_flash.delete(:notice)
flash[:notice] = notice
end
if error = response_status_and_flash.delete(:error)
flash[:error] = error
end
if success = response_status_and_flash.delete(:success)
flash[:success] = success
end
if other_flashes = response_status_and_flash.delete(:flash)
flash.update(other_flashes)
end
super(options, response_status_and_flash)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment