Simple Flash Message Displayer

Sometimes you don’t need fancy flash message handling in your application. Here’s a little helper method for those occasions:

def display_flash
  flash.map do |level, message|
    content_tag("div", message, :class => "flash-#{level}")
  end
end

Example

Say you do the following somewhere:

flash[:info] = "Your pizza has been ordered." 
flash[:warn] = "The pizza will unfortunately be cold." 

The output of display_flash will be:

<div class="flash-info">Your pizza has been ordered.</div>
<div class="flash-warn">The pizza will unfortunately be cold.</div>

Simple and easy, like it should be.