RSS Feed

Rails flash messages dried up.

Posted on Sunday, May 17, 2009 in Do it yourself guides

Im working on this so I can have less of this <%= flash[:notice] %> in my html templates.

def render_flash(flash)
    [:notice, :warning].each do |key|
      if flash.is_a?(Hash) && flash.has_key?(key) && !flash[key].blank?
        content_tag(:span, :class => key.to_s.downcase) do
          flash[key]
        end
      end
    end
  end

Leave a Comment

You must be logged in to post a comment.