Arpit Agarwal
Arpit Agarwal

Reputation: 527

How can I display flash messages with devise using Semantic-UI in Rails?

For learning purpose I have created a user model with devise gem and for styling I am using semantic-ui. How can I display flash messages with semantic-ui styling in devise when user logs in or logs out?

Upvotes: 1

Views: 794

Answers (1)

Shabini Rajadas
Shabini Rajadas

Reputation: 761

To display flash messages, create a method in application helper, to find out the type of flash message, something like this,

def flash_class(type)
 case type
  when "success" then "ui green message"
  #add in the other options and the styles for it.
 end
end

And then in views, add

<% flash.each do |key, value|%>
<div class="<%= flash_class(key) %> closable">
<i class = "close icon"></i>
<%= value %>
</div>
<% end %>

Add styles for the class .message.closable{ }

For further details please check this link https://coderwall.com/p/7gqmog/display-flash-messages-with-semantic-ui-in-rails. A detailed explanation available here.

Upvotes: 2

Related Questions