From b163754bc55c3d23e62071d39451c2fbe4579e99 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Wed, 10 Jul 2013 17:17:46 +0200 Subject: Add documentation for add_flash_types [ci skip] Document a little bit the ActionController::Flash::add_flash_types class method. --- actionpack/lib/action_controller/metal/flash.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'actionpack/lib/action_controller/metal/flash.rb') 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 alert and notice 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) -- cgit v1.2.3