application_helper.rb 582 B

1234567891011121314151617181920
  1. module ApplicationHelper
  2. def bootstrap_class_for(flash_type)
  3. {
  4. success: "alert-success",
  5. error: "alert-danger",
  6. alert: "alert-warning",
  7. notice: "alert-info"
  8. }.stringify_keys[flash_type.to_s] || flash_type.to_s
  9. end
  10. def flash_messages(opts={})
  11. flash.each do |msg_type, message|
  12. concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)}") do
  13. concat content_tag(:button, content_tag(:span, "×"), class: "close", data: { dismiss: 'alert' })
  14. concat message
  15. end)
  16. end
  17. nil
  18. end
  19. end