[fix #474] display devise errors with flashes
This commit is contained in:
parent
2f9f74aa9f
commit
8d008a51d0
3 changed files with 26 additions and 7 deletions
8
app/helpers/application_helper.rb
Normal file
8
app/helpers/application_helper.rb
Normal 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
|
8
app/helpers/devise_helper.rb
Normal file
8
app/helpers/devise_helper.rb
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue