module ActionController::Flash::ClassMethods
def add_flash_types(*types)
This method will automatically define a new method for each of the given
<%= warning %>
# in your view
redirect_to user_path(@user), warning: "Incomplete profile"
# in your controller
end
add_flash_types :warning
class ApplicationController < ActionController::Base
# in application_controller.rb
your controllers and views. For instance:
flash types other than the default alert and notice in
Creates new flash types. You can pass as many types as you want to create
def add_flash_types(*types) types.each do |type| next if _flash_types.include?(type) define_method(type) do request.flash[type] end helper_method type self._flash_types += [type] end end