diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2009-12-17 16:37:11 -0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2009-12-17 16:37:11 -0800 |
commit | fa575973b1ad5adb7115a18c4c1c7c31500e73b2 (patch) | |
tree | 6fb71516dfd7e24758825093ad37337205669e26 /actionpack/lib/action_controller/metal/flash.rb | |
parent | 2bfa477128ef36e5664709684b51c20bebf1ee70 (diff) | |
download | rails-fa575973b1ad5adb7115a18c4c1c7c31500e73b2.tar.gz rails-fa575973b1ad5adb7115a18c4c1c7c31500e73b2.tar.bz2 rails-fa575973b1ad5adb7115a18c4c1c7c31500e73b2.zip |
Added alert/notice from 2-3-stable and refactored redirect_to into just living in Redirector [DHH]
Diffstat (limited to 'actionpack/lib/action_controller/metal/flash.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/flash.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/flash.rb b/actionpack/lib/action_controller/metal/flash.rb index 9d08ed6081..ae343444e2 100644 --- a/actionpack/lib/action_controller/metal/flash.rb +++ b/actionpack/lib/action_controller/metal/flash.rb @@ -30,6 +30,10 @@ module ActionController #:nodoc: include Session + included do + helper_method :alert, :notice + end + class FlashNow #:nodoc: def initialize(flash) @flash = flash @@ -147,6 +151,27 @@ module ActionController #:nodoc: @_flash end + # Convenience accessor for flash[:alert] + def alert + flash[:alert] + end + + # Convenience accessor for flash[:alert]= + def alert=(message) + flash[:alert] = message + end + + # Convenience accessor for flash[:notice] + def notice + flash[:notice] + end + + # Convenience accessor for flash[:notice]= + def notice=(message) + flash[:notice] = message + end + + protected def process_action(method_name) @_flash = nil @@ -159,5 +184,21 @@ module ActionController #:nodoc: super @_flash = nil end + + 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 other_flashes = response_status_and_flash.delete(:flash) + flash.update(other_flashes) + end + + super(options, response_status_and_flash) + end end end |