diff options
author | Steve Klabnik <steve@steveklabnik.com> | 2013-07-10 11:39:31 -0700 |
---|---|---|
committer | Steve Klabnik <steve@steveklabnik.com> | 2013-07-10 11:39:31 -0700 |
commit | ddf79ab15b7e47a3ed98c44da7665dbc624fdbf6 (patch) | |
tree | 828084732eef29fa146e889e82fb88378d6e56f6 | |
parent | 78f7d5b652000dbb1a11d34fe370c3fa82de840c (diff) | |
parent | b163754bc55c3d23e62071d39451c2fbe4579e99 (diff) | |
download | rails-ddf79ab15b7e47a3ed98c44da7665dbc624fdbf6.tar.gz rails-ddf79ab15b7e47a3ed98c44da7665dbc624fdbf6.tar.bz2 rails-ddf79ab15b7e47a3ed98c44da7665dbc624fdbf6.zip |
Merge pull request #11394 from robin850/patch-8
Add documentation for add_flash_types [ci skip]
-rw-r--r-- | actionpack/lib/action_controller/metal/flash.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/flash.rb b/actionpack/lib/action_controller/metal/flash.rb index b078beb675..1d77e331f8 100644 --- a/actionpack/lib/action_controller/metal/flash.rb +++ b/actionpack/lib/action_controller/metal/flash.rb @@ -11,6 +11,23 @@ module ActionController #:nodoc: end module ClassMethods + # Creates new flash types. You can pass as many types as you want to create + # flash types other than the default <tt>alert</tt> and <tt>notice</tt> in + # your controllers and views. For instance: + # + # # in application_controller.rb + # class ApplicationController < ActionController::Base + # add_flash_types :warning + # end + # + # # in your controller + # redirect_to user_path(@user), warning: "Incomplete profile" + # + # # in your view + # <%= warning %> + # + # This method will automatically define a new method for each of the given + # names, and it will be available in your views. def add_flash_types(*types) types.each do |type| next if _flash_types.include?(type) |