Module: AgilideeDevise::ApplicationHelper

Defined in:
app/helpers/agilidee_devise/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_devise_error_messages!Object



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

def bootstrap_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-danger alert-block alert-devise">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <h5>#{sentence}</h5>
    <ul>#{messages}</ul>
  </div>
  HTML

  html.html_safe
end

#devise_panel(title, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/agilidee_devise/application_helper.rb', line 21

def devise_panel(title, &block)
  (:div, class: "panel panel-default panel-devise") do
    heading = (:div, class: "panel-heading") do
      (:h1, class: "panel-title") { title }
    end

    body = (:div, class: "panel-body", &block)

    heading + body
  end
end