aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides
diff options
context:
space:
mode:
authorTore Darell <toredarell@gmail.com>2008-10-10 17:43:39 +0200
committerKarel Minarik <karmi@karmi.cz>2008-10-14 10:20:12 +0200
commit53f56966130f0a48589d3f06d85ca186fb84005f (patch)
treead918d50cb7e056892cb66345d6736cb27bb3304 /railties/doc/guides
parentb38a80323f9cef4415c110b0b05016f98613e870 (diff)
downloadrails-53f56966130f0a48589d3f06d85ca186fb84005f.tar.gz
rails-53f56966130f0a48589d3f06d85ca186fb84005f.tar.bz2
rails-53f56966130f0a48589d3f06d85ca186fb84005f.zip
Add description of flash.now
Diffstat (limited to 'railties/doc/guides')
-rw-r--r--railties/doc/guides/actioncontroller/session.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/railties/doc/guides/actioncontroller/session.txt b/railties/doc/guides/actioncontroller/session.txt
index 0a44bfd802..467cffbf85 100644
--- a/railties/doc/guides/actioncontroller/session.txt
+++ b/railties/doc/guides/actioncontroller/session.txt
@@ -162,3 +162,24 @@ class MainController < ApplicationController
end
------------------------------------------
+
+==== flash.now ====
+
+By default, adding values to the flash will make them available to the next request, but sometimes you may want to access those values in the same request. For example, if the `create` action fails to save a resource and you render the `new` template directly, that's not going to result in a new request, but you may still want to display a message using the flash. To do this, you can use `flash.now` in the same way you use the normal `flash`:
+
+[source, ruby]
+------------------------------------------
+class ClientsController < ApplicationController
+
+ def create
+ @client = Client.new(params[:client])
+ if @client.save
+ # ...
+ else
+ flash.now[:error] = "Could not save client"
+ render :action => "new"
+ end
+ end
+
+end
+------------------------------------------