Permalink
Browse files

Changed explanation for gflash a bit.

  • Loading branch information...
Robin Brouwer
Robin Brouwer committed Jan 25, 2012
1 parent 82709a2 commit 43bcf799d654bfebdbc8a78a28c59653d53f9bbd
Showing with 14 additions and 1 deletion.
  1. +14 −1 README.md
View
@@ -233,7 +233,20 @@ This is done inside the Controller and works like this:
gflash :success => { :value => true, :time => 2000, :class_name => "my_class", :sticky => true }
gflash :error => { :value => "Custom error", :time => 3000, :class_name => "my_error_class", :sticky => false }
-When you don't pass a `:value` it uses the locale. Same goes for when you pass `true` to `:value`.
+When you don't pass a `:value` it uses the locale. Same goes for when you pass `true` to `:value`. When you give `:value` a String, that String will be used to display the message. Here's another example:
+
+ def create
+ @user = User.new(params[:user])
+ if @user.save
+ gflash :success => { :value => "Account has been created!", :time => 5000 },
+ :notice => { :value => "You have received an e-mail notification.", :sticky => true }
+ redirect_to :root
+ else
+ gflash :error => { :value => "Something went wrong.", :time => 4000 },
+ :warning => { :value => "Some fields weren't filled in correctly.", :time => 7000 }
+ render :new
+ end
+ end
You can also use gflash directly inside the `redirect_to` method.

0 comments on commit 43bcf79

Please sign in to comment.