Module: DeviseHelper

Defined in:
app/helpers/devise_helper.rb

Overview

The DeviseHelper module.

Instance Method Summary (collapse)

Instance Method Details

- (Object) devise_error_messages!

Handle device error messages with the bootstrap theme.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/devise_helper.rb', line 7

def devise_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-info alert-dismissable">

    <a class="close" data-dismiss="alert" href="#">×</a>
    <i class="icon-info-sign"></i>
    #{sentence}
    #{messages}
  </div>

  HTML

  html.html_safe
end