Module: DeviseBootstrapErrorsHelper

Defined in:
app/helpers/devise_bootstrap_errors_helper.rb

Instance Method Summary collapse

Instance Method Details

#devise_bootstrap_error_messages!Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/devise_bootstrap_errors_helper.rb', line 2

def devise_bootstrap_error_messages!
  return '' if resource.errors.empty?

  messages = resource.errors.full_messages.map { |msg| (:li, msg) }.join
  sentence = I18n.t('errors.messages.not_saved',
                    count: resource.errors.count,
                    resource: resource.class.model_name.human.downcase)

  html = <<-HTML
  <div class="alert alert-danger alert-block devise-bs">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <h5>#{sentence}</h5>
    <ul>#{messages}</ul>
  </div>
  HTML

  html.html_safe
end