-
-
Save mihir-kumar-thakur/c4e497e7ad4f1d05c374b1c3b17198fd to your computer and use it in GitHub Desktop.
rails flash messages with bootstrap 4
This file contains hidden or 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 hidden or 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 hidden or 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