#18
Apr 13, 2007

Looping Through Flash

Displaying flash messages in the layout can be a pain at times. In this episode you will learn an easy way to display any kind of flash message by looping through the hash.
Tags: views
Download (6.3 MB, 1:44)
alternative download for iPod & Apple TV (2.7 MB, 1:44)
<!-- layouts/application.rhtml -->
<% flash.each do |key, msg| %>
  <%= content_tag :div, msg, :id => key %>
<% end %>

4 comments

Olek Poplavsky Jul 22, 2007 at 07:40

This is fine approach, but it will display errors mixed with warnings in no particular order, and that is not good in my opinion. I prefer messages sorted in order of decreasing severity: [:error, :warning, :notice, :message]

I have some code that does it, but I written it at the very beginning of studying ruby/rails, so I will not posit it here, it is not pretty ;)


Ryan Bates Jul 22, 2007 at 08:15

How about this: http://pastie.caboo.se/81153


meekish Jan 25, 2008 at 14:15

Here's a HAML version: http://pastie.textmate.org/143587


kino May 23, 2008 at 01:55

Philosophy can thereby determine in its totality, in other words, the Antinomies.

Add your comment:

(SKIP THIS ONE)

(required)

(not shown)


(required)

subscribe:
sponsored by:
if you want to help:
required:
Get Quicktime Player