Last active
January 23, 2019 02:47
-
-
Save WolfpackGaming-SavSin/d5d347d078558c54851d254dfc35476b to your computer and use it in GitHub Desktop.
Flash Messages using Semantic-UI and Devise
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
<!-- This is the partial I use to render messages to the layout --> | |
<% flash.each do | message_type, message_content | %> | |
<% flash.delete(:timedout) %> # Remove the :timedout key from the flash if it's present. | |
<div class="ui <%= flash_class(message_type) %> message transition"> | |
<i class="close icon"></i> | |
<div class="header"> | |
<%= message_content %> | |
</div> | |
</div> | |
<% end %> |
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
<!-- Add this to your application layout so that the messages partial is displayed --> | |
<div class="ui container"> | |
<%= render 'layouts/messages' %> | |
<%= yield %> | |
</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
# Add this helper function to your application_helper.rb file. | |
def flash_class(level) | |
case level | |
when "success" | |
"positive" | |
when "error" | |
"negative" | |
when "alert" | |
"negative" | |
when "notice" | |
"info" | |
else | |
"info" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment