Skip to content

Instantly share code, notes, and snippets.

@willywg
Created May 10, 2018 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willywg/b78be8e547e974dc622dd0d2a01fa017 to your computer and use it in GitHub Desktop.
Save willywg/b78be8e547e974dc622dd0d2a01fa017 to your computer and use it in GitHub Desktop.
Rails flash messages helper for bootstrap 4 with slim
- flash.each do |type, msg|
div class=("alert #{bootstrap_class_for_flash(type)} alert-dismissable fade show")
= msg
button.close data-dismiss="alert" ×
module BootstrapFlashMessageHelper
FLASH_TYPES = {
'success' => 'alert-success',
'error' => 'alert-danger',
'alert' => 'alert-warning',
'notice' => 'alert-info'
}
def bootstrap_class_for_flash(flash_type)
FLASH_TYPES[flash_type] || flash_type.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment