1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add documentation for add_flash_types [ci skip]

Document a little bit the ActionController::Flash::add_flash_types
class method.
This commit is contained in:
Robin Dupret 2013-07-10 17:17:46 +02:00
parent 4d733d2dd4
commit b163754bc5

View file

@ -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)