Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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