diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 000000000..8aed47dc2 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/helpers/devise_helper.rb b/app/helpers/devise_helper.rb new file mode 100644 index 000000000..14afe134f --- /dev/null +++ b/app/helpers/devise_helper.rb @@ -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 diff --git a/app/views/layouts/_flash_messages.html.haml b/app/views/layouts/_flash_messages.html.haml index 730c11fde..1c1ec728b 100644 --- a/app/views/layouts/_flash_messages.html.haml +++ b/app/views/layouts/_flash_messages.html.haml @@ -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