Permalink
Browse files

Merge pull request #11394 from robin850/patch-8

Add documentation for add_flash_types [ci skip]
  • Loading branch information...
2 parents 78f7d5b + b163754 commit ddf79ab15b7e47a3ed98c44da7665dbc624fdbf6 @steveklabnik steveklabnik committed Jul 10, 2013
Showing with 17 additions and 0 deletions.
  1. +17 −0 actionpack/lib/action_controller/metal/flash.rb
@@ -11,6 +11,23 @@ module Flash
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)

0 comments on commit ddf79ab

Please sign in to comment.