in flash growls css jquery rails ruby rubyonrails programming javascript ~ read.

Simple CSS and JS for Rails flash messages

In your application.html.haml add

    #flash.flash
      - flash.each do |key, value|
        %div{ id: "flash-#{key}"}
          %p.flash-message=h value

in your css file add

.flash {
  position: absolute;
  width: 100%;
  top: 0;

  .flash-message {
    text-align: center;
    background: $corange;
    padding: 3px 0 3px 0;
    margin: 0 0 0 0;
  }
}

and in the JS file call this function

var flash = function() {  
      var flashMessage = $('#flash');

      if (!!flashMessage) {
        setTimeout(function() {
          flashMessage.fadeOut('slow');
        }, 2000)
      }
    }

flash();