aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/flash.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-12-29 15:46:12 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2009-12-29 15:46:12 -0800
commitb27a3e8da39484d8a02d3b9c1e4dc3cb60ddcce7 (patch)
tree372a4af6df43eb8bed19c11e55b2f70907d60507 /actionpack/lib/action_controller/metal/flash.rb
parentada895e8cac855a2f248aafdb92457365f062d07 (diff)
parentb354496bda901cb0af499d6f3dff17a96a834a67 (diff)
downloadrails-b27a3e8da39484d8a02d3b9c1e4dc3cb60ddcce7.tar.gz
rails-b27a3e8da39484d8a02d3b9c1e4dc3cb60ddcce7.tar.bz2
rails-b27a3e8da39484d8a02d3b9c1e4dc3cb60ddcce7.zip
Merge branch 'master' of git://github.com/mikel/rails into mail
Conflicts: actionmailer/lib/action_mailer.rb
Diffstat (limited to 'actionpack/lib/action_controller/metal/flash.rb')
-rw-r--r--actionpack/lib/action_controller/metal/flash.rb58
1 files changed, 49 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/metal/flash.rb b/actionpack/lib/action_controller/metal/flash.rb
index f43900faa0..581ff6109e 100644
--- a/actionpack/lib/action_controller/metal/flash.rb
+++ b/actionpack/lib/action_controller/metal/flash.rb
@@ -28,7 +28,9 @@ module ActionController #:nodoc:
module Flash
extend ActiveSupport::Concern
- include Session
+ included do
+ helper_method :alert, :notice
+ end
class FlashNow #:nodoc:
def initialize(flash)
@@ -133,10 +135,44 @@ module ActionController #:nodoc:
Array(key || keys).each { |k| used ? @used << k : @used.delete(k) }
return key ? self[key] : self
end
+ end
+
+ # Access the contents of the flash. Use <tt>flash["notice"]</tt> to
+ # read a notice you put there or <tt>flash["notice"] = "hello"</tt>
+ # to put a new one.
+ def flash #:doc:
+ unless @_flash
+ @_flash = session["flash"] || FlashHash.new
+ @_flash.sweep
end
+ @_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
super
@_flash.store(session) if @_flash
@_flash = nil
@@ -147,16 +183,20 @@ module ActionController #:nodoc:
@_flash = nil
end
- # Access the contents of the flash. Use <tt>flash["notice"]</tt> to
- # read a notice you put there or <tt>flash["notice"] = "hello"</tt>
- # to put a new one.
- def flash #:doc:
- unless @_flash
- @_flash = session["flash"] || FlashHash.new
- @_flash.sweep
+ 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
- @_flash
+ super(options, response_status_and_flash)
end
end
end