devise flash message being notice

So I'm working on setting up my flash messages. Currently my _messages looks like this:

<% flash.each do |message_type, message| %>
  <%= content_tag(:div, message,  class: "alert alert-#{message_type}", role: "alert") %>
<% end %>

however with devise they keep on using alert-notice. Which via bootstrap obviously have no colors connected to it. How do I go about changing the devise default to one of the 4 selected?

Upvotes: 4

Views: 9497

Answers (2)

VendezTrouvez
VendezTrouvez

Reputation: 131

The simplest way is that:

<div class="row">
  <div class="col-xs-10 col-xs-offset-1">
    <% flash.each do |type, msg| %>
      <% if type == "notice" %>
        <div class="alert alert-success">
      <% elsif type == "alert" %>
        <div class="alert alert-danger">
      <% else %>
        <div class='alert alert-<%= "#{type}" %>'>
      <% end %>
      <a href="#" class="close" data-dismiss="alert">&#215;</a>
      <ul>
        <li>
          <%= msg %>
        </li>
      </ul>
    <% end %>
  </div>
</div>

Upvotes: 7

Tom Fast
Tom Fast

Reputation: 1158

I don't think devise allows you to customize, but you could override some of its methods. Checkout this GitHub issue for some examples: https://github.com/plataformatec/devise/issues/2282

Upvotes: 1

Related Questions