[fix #474] display devise errors with flashes

This commit is contained in:
Mathieu Magnin 2017-06-21 16:14:41 +02:00
parent 2f9f74aa9f
commit 8d008a51d0
3 changed files with 26 additions and 7 deletions

View file

@ -0,0 +1,8 @@
module ApplicationHelper
def flash_class(level)
case level
when "notice" then "alert-success"
when "alert" then "alert-danger"
end
end
end

View file

@ -0,0 +1,8 @@
module DeviseHelper
def devise_error_messages!
if resource.errors.full_messages.any?
flash.now[:alert] = resource.errors.full_messages
end
''
end
end

View file

@ -1,8 +1,11 @@
- if flash.notice.present? || flash.alert.present?
- if flash.any?
#flash_message.center
- if flash.notice.present?
.alert.alert-success
= flash.notice
- if flash.alert.present?
.alert.alert-danger
= flash.alert.html_safe
- flash.each do |key, value|
- if value.class == Array
.alert{ class: flash_class(key) }
- value.each do |message|
= message
%br
- else
.alert{ class: flash_class(key) }
= value