Check if flash is not initial

Hi all

How can I show the div only, when the flash message is not initial?

The div:

<div class="ui red mini message error"><%= get_flash(@conn, :error) %></div>

Thanks

2 Likes

I have this

<%= if get_flash(@conn, :error) do  %>
        <div class="alert alert-danger alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
          <%= get_flash(@conn, :error) %>
        </div>
<%= end %>
5 Likes

Or simply hide it with some CSS (only works if div contains no spaces or other markup):

.message.error:empty {
  display: none;
}
3 Likes