Skip to content

Instantly share code, notes, and snippets.

@WolfpackGaming-SavSin
Last active January 23, 2019 02:47
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 WolfpackGaming-SavSin/d5d347d078558c54851d254dfc35476b to your computer and use it in GitHub Desktop.
Save WolfpackGaming-SavSin/d5d347d078558c54851d254dfc35476b to your computer and use it in GitHub Desktop.
Flash Messages using Semantic-UI and Devise
<!-- 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 %>
<!-- Add this to your application layout so that the messages partial is displayed -->
<div class="ui container">
<%= render 'layouts/messages' %>
<%= yield %>
</div>
# 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