ruby on rails flash messages - :alert :error :notice and :success?

Chip picture Chip · Sep 28, 2011 · Viewed 42.6k times · Source

In several of my controllers, I have redirects/flash messages

redirect_to products_url, :notice => "message here", 
redirect_to states_url, :error => "oops!" etc... 

In my sessions controller, however, upon successful authentication, I have flash[:success] = "welcome!" redirect_to user

I'd like to be able in my other controllers to do something like :success => "yay!"

This is mostly for cosmetic/consistency purposes, but are :notice, :alert and :error the only flash-types available / can I add additional types? Am I making sense?

Thanks!

Answer

tlbrack picture tlbrack · Sep 28, 2011

I believe without changes, this is as close as you'll get:

redirect_to user_path(@user), :flash => { :success => "Message" }

Here's some additional notes regarding the friendly flash syntax addition.