Last active
August 9, 2021 02:16
-
-
Save pawelztef/f9a821695e58ec685463be7bf691da70 to your computer and use it in GitHub Desktop.
rails flash messages with bootstrap 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<% flash.each do |type, msg| %> | |
<div class="alert <%= bootstrap_class_for_flash(type) %> alert-dismissable fade show"> | |
<%= msg %> | |
<button class="close" data-dismiss="alert">x</button> | |
</div> | |
<% end %> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render partial: 'flash', flash: flash %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def bootstrap_class_for_flash(flash_type) | |
case flash_type | |
when 'success' | |
'alert-success' | |
when 'error' | |
'alert-danger' | |
when 'alert' | |
'alert-warning' | |
when 'notice' | |
'alert-info' | |
else | |
flash_type.to_s | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment