doc/api/classes/ActionController/Flash/FlashHash.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: ActionController::Flash::FlashHash</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">ActionController::Flash::FlashHash</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/vendor/rails/actionpack/lib/action_controller/flash_rb.html">
vendor/rails/actionpack/lib/action_controller/flash.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Hash
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000172">discard</a>
<a href="#M000171">keep</a>
<a href="#M000170">now</a>
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="aliases-list">
<h3 class="section-bar">External Aliases</h3>
<div class="name-list">
<table summary="aliases">
<tr class="top-aligned-row context-row">
<td class="context-item-name">update</td>
<td>-></td>
<td class="context-item-value">merge!</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000172" class="method-detail">
<a name="M000172"></a>
<div class="method-heading">
<a href="#M000172" class="method-signature">
<span class="method-name">discard</span><span class="method-args">(k = nil)</span>
</a>
</div>
<div class="method-description">
<p>
Marks the entire flash or a single flash entry to be discarded by the end
of the current action
</p>
<pre>
flash.keep # keep entire flash available for the next action
flash.discard(:warning) # discard the "warning" entry (it'll still be available for the current action)
</pre>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000172-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000172-source">
<pre>
<span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/flash.rb, line 103</span>
103: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">discard</span>(<span class="ruby-identifier">k</span> = <span class="ruby-keyword kw">nil</span>)
104: <span class="ruby-identifier">use</span>(<span class="ruby-identifier">k</span>)
105: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000171" class="method-detail">
<a name="M000171"></a>
<div class="method-heading">
<a href="#M000171" class="method-signature">
<span class="method-name">keep</span><span class="method-args">(k = nil)</span>
</a>
</div>
<div class="method-description">
<p>
Keeps either the entire current flash or a specific flash entry available
for the next action:
</p>
<pre>
flash.keep # keeps the entire flash
flash.keep(:notice) # keeps only the "notice" entry, the rest of the flash is discarded
</pre>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000171-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000171-source">
<pre>
<span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/flash.rb, line 95</span>
95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">keep</span>(<span class="ruby-identifier">k</span> = <span class="ruby-keyword kw">nil</span>)
96: <span class="ruby-identifier">use</span>(<span class="ruby-identifier">k</span>, <span class="ruby-keyword kw">false</span>)
97: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000170" class="method-detail">
<a name="M000170"></a>
<div class="method-heading">
<a href="#M000170" class="method-signature">
<span class="method-name">now</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
Sets a flash that will not be available to the next action, only to the
current.
</p>
<pre>
flash.now[:message] = "Hello current action"
</pre>
<p>
This method enables you to use the flash as a central messaging system in
your app. When you need to pass an object to the next action, you use the
standard flash assign (<tt>[]=</tt>). When you need to pass an object to
the current action, you use <tt><a
href="FlashHash.html#M000170">now</a></tt>, and your object will vanish
when the current action is done.
</p>
<p>
Entries set via <tt><a href="FlashHash.html#M000170">now</a></tt> are
accessed the same way as standard entries:
<tt>flash[‘my-key’]</tt>.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000170-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000170-source">
<pre>
<span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/flash.rb, line 87</span>
87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">now</span>
88: <span class="ruby-constant">FlashNow</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">self</span>
89: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>