BS3: devise & flash messaging.

This commit is contained in:
Ilya Konanykhin
2016-12-21 17:17:54 +06:00
parent 508a1d8d06
commit ec6b58680b
13 changed files with 166 additions and 161 deletions
+7 -10
View File
@@ -1,21 +1,18 @@
module DeviseHelper
# A simple way to show error messages for the current devise resource. If you need
# to customize this method, you can either overwrite it in your application helpers or
# copy the views to your application.
#
# This method is intended to stay simple and it is unlikely that we are going to change
# it to add more behavior or options.
def devise_error_messages!
return "" if resource.errors.empty?
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:p, msg, :class => "alert") }.join
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }
sentence = I18n.t("errors.messages.not_saved",
:count => resource.errors.count,
:resource => resource.class.model_name.human.downcase)
html = <<-HTML
<p>#{sentence}</p>
#{messages}
<div class="alert alert-danger">#{sentence}
<ul>
#{messages.join}
</ul>
</div>
HTML
html.html_safe