Uber clean flash div in application helper
# flash_div
# use to display specified flash messages
# defaults to standard set: [:success, :message, :warning]
# example:
# <%= flash_div %>
# example with other keys:
# <%= flash_div :notice, :violation %>
# renders like:
# <div class="flash flash-success">Positive - successful action</div>
# <div class="flash flash-message">Neutral - reminders, status</div>
# <div class="flash flash-warning">Negative - error, unsuccessful action</div>
def flash_div(*keys)
keys = [:success, :message, :warning] if keys.empty?
keys.compact.collect do |key|
flash[key].blank? ? nil : content_tag(:div, flash[key], :class => "flash flash-#{key}")
end.compact.join("\n")
end
Original snippet written by Jon Kinney
Last updated at 10:20 AM on Aug 08, 2008