Skip to content

Commit b163754

Browse files
committed
Add documentation for add_flash_types [ci skip]
Document a little bit the ActionController::Flash::add_flash_types class method.
1 parent 4d733d2 commit b163754

File tree

1 file changed

+17
-0
lines changed
  • actionpack/lib/action_controller/metal

1 file changed

+17
-0
lines changed

actionpack/lib/action_controller/metal/flash.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ module Flash
1111
end
1212

1313
module ClassMethods
14+
# Creates new flash types. You can pass as many types as you want to create
15+
# flash types other than the default <tt>alert</tt> and <tt>notice</tt> in
16+
# your controllers and views. For instance:
17+
#
18+
# # in application_controller.rb
19+
# class ApplicationController < ActionController::Base
20+
# add_flash_types :warning
21+
# end
22+
#
23+
# # in your controller
24+
# redirect_to user_path(@user), warning: "Incomplete profile"
25+
#
26+
# # in your view
27+
# <%= warning %>
28+
#
29+
# This method will automatically define a new method for each of the given
30+
# names, and it will be available in your views.
1431
def add_flash_types(*types)
1532
types.each do |type|
1633
next if _flash_types.include?(type)

0 commit comments

Comments
 (0)