What flash message types are available in Rails?

So far I've got:

  • :notice
  • :alert
  • :error

but is there definitive list, that can be used in place, such as in redirect_to path, :error => "Oh no!"?


Hauleth is correct that you can use any symbol, but right now, :notice and :alert are the only ones you can pass directly into redirect_to (according to flash.rb in Rails source), as you specifically mention:

redirect_to path, :error => "Oh no!" # Will not work

If you want a different flash type such as :error (or :success), you must pass those in through the :flash key, like so:

redirect_to path, :flash => { :error => "Oh no!" }

For information on how to register your custom flash types so that, like :notice and :alert, you can pass them directly in to redirect_to, see this StackOverflow Q&A: https://stackoverflow.com/a/3848759/995663

Update: According to this commit, it seems Rails 4 will make this easier by allowing you to register custom flash types by calling add_flash_types :error in ApplicationController.


No, as a flash type you can use any symbol, even your own.