Rails flash messages helper


/ Published in: Rails
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #FLASH_TYPES = [:error, :warning, :success, :message]
  2.  
  3. def display_flash(type = nil)
  4. html = ""
  5.  
  6. if type.nil?
  7. FLASH_TYPES.each { |name| html << display_flash(name) }
  8. else
  9. return flash[type].blank? ? "" : "<div class="#{type}"><p>#{flash[type]}</p></div>"
  10. end
  11.  
  12. html
  13. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.