I am using Rails 4, Twitter Bootstrap 3.0, and Devise 3.0. I am trying to get identical looking flash messages for devise and the rest of my site. So far I have this:
Within "app/views/layouts/application.html.erb":
<%= render 'layouts/messages' %>
"app/views/layouts/_messages.html.erb":
<% devise_flash %>
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>">
<a href="#" data-dismiss="alert" class="close">×</a>
<%= value %>
</div>
<% end %>
I have created a "app/helpers/devise_helper.rb" in order to override the default devise error messages:
module DeviseHelper
def devise_error_messages!
end
end
"app/helpers/application_helper.rb":
def devise_flash
if controller.devise_controller? && resource.errors.any?
flash.now[:error] = flash[:error].to_a.concat resource.errors.full_messages
flash.now[:error].uniq!
end
end
"app/assets/stylesheets/custom.css.scss":
.alert-error {
background-color: #f2dede;
border-color: #eed3d7;
color: #b94a48;
text-align: center; }
.alert-alert {
background-color: #f2dede;
border-color: #eed3d7;
color: #b94a48;
text-align: center; }
.alert-success {
background-color: #dff0d8;
border-color: #d6e9c6;
color: #468847;
text-align: center; }
.alert-notice {
background-color: #dff0d8;
border-color: #d6e9c6;
color: #468847;
text-align: center; }
It displays normal flash messages fine but the issue is when I have a devise error. It looks like this:
I am trying to list the errors more like this:
I don't want the errors to be surrounded by "". It does not need to have the bullets, but I want it to be listed vertically. I think I need to edit my devise_flash method in the "app/helpers/application_helper.rb" file.
How can I do this?