Changeset 7428
- Timestamp:
- 09/09/07 21:54:59 (1 year ago)
- Files:
-
- trunk/actionpack/lib/action_controller/flash.rb (modified) (7 diffs)
- trunk/actionpack/test/controller/flash_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/flash.rb
r7383 r7428 1 1 module ActionController #:nodoc: 2 2 # The flash provides a way to pass temporary objects between actions. Anything you place in the flash will be exposed 3 # to the very next action and then cleared out. This is a great way of doing notices and alerts, such as a create action4 # that sets <tt>flash[:notice] = "Successfully created"</tt> before redirecting to a display action that can then expose5 # the flash to its template. Actually, that exposure is automatically done. Example:3 # to the very next action and then cleared out. This is a great way of doing notices and alerts, such as a create 4 # action that sets <tt>flash[:notice] = "Successfully created"</tt> before redirecting to a display action that can 5 # then expose the flash to its template. Actually, that exposure is automatically done. Example: 6 6 # 7 7 # class WeblogController < ActionController::Base … … 20 20 # <% if flash[:notice] %><div class="notice"><%= flash[:notice] %></div><% end %> 21 21 # 22 # This example just places a string in the flash, but you can put any object in there. And of course, you can put as many23 # as you like at a time too. Just remember: They'll be gone by the time the next action has been performed.22 # This example just places a string in the flash, but you can put any object in there. And of course, you can put as 23 # many as you like at a time too. Just remember: They'll be gone by the time the next action has been performed. 24 24 # 25 25 # See docs on the FlashHash class for more details about the flash. … … 86 86 # Entries set via <tt>now</tt> are accessed the same way as standard entries: <tt>flash['my-key']</tt>. 87 87 def now 88 FlashNow.new self88 FlashNow.new(self) 89 89 end 90 90 … … 118 118 end 119 119 120 (@used.keys - keys).each{|k| @used.delete k } # clean up after keys that could have been left over by calling reject! or shift on the flash 120 # clean up after keys that could have been left over by calling reject! or shift on the flash 121 (@used.keys - keys).each{ |k| @used.delete(k) } 121 122 end 122 123 … … 131 132 @used[k] = v 132 133 else 133 keys.each{ |key| use key, v}134 keys.each{ |key| use(key, v) } 134 135 end 135 136 end … … 137 138 138 139 module InstanceMethods #:nodoc: 139 140 140 protected 141 141 def reset_session_with_flash … … 164 164 end 165 165 166 # deprecated. use <tt>flash.keep</tt> instead167 def keep_flash #:doc:168 ActiveSupport::Deprecation.warn 'keep_flash is deprecated; use flash.keep instead.', caller169 flash.keep170 end171 172 166 private 173 167 def assign_shortcuts_with_flash(request, response) #:nodoc: trunk/actionpack/test/controller/flash_test.rb
r6670 r7428 32 32 @flash_copy = {}.update flash 33 33 @flashy = flash["that"] 34 silence_warnings { keep_flash }34 flash.keep 35 35 render :inline => "hello" 36 36 end … … 95 95 get :set_flash 96 96 97 assert_deprecated(/keep_flash/) { get :use_flash_and_keep_it }97 get :use_flash_and_keep_it 98 98 assert_equal "hello", @response.template.assigns["flash_copy"]["that"] 99 99 assert_equal "hello", @response.template.assigns["flashy"]