Module: UserHelper

Defined in:
app/helpers/user_helper.rb

Instance Method Summary collapse

Instance Method Details

#devise_error_messages!Object



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

def devise_error_messages!
  flash_alerts = []
  error_key = 'errors.messages.not_saved'

  if !flash.empty?
    flash_alerts.push(flash[:error]) if flash[:error]
    flash_alerts.push(flash[:alert]) if flash[:alert]
    flash_alerts.push(flash[:notice]) if flash[:notice]
    error_key = 'devise.failure.invalid'
  end

  return "" if resource.errors.empty? && flash_alerts.empty?
  errors = resource.errors.empty? ? flash_alerts : resource.errors.full_messages

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

  html = <<-HTML
  <div id="error_explanation">
    <h2>#{sentence}</h2>
    <ul>#{messages}</ul>
  </div>
  HTML

  html.html_safe
end

#field_typesObject



31
32
33
# File 'app/helpers/user_helper.rb', line 31

def field_types
  FormFieldType.sys(_sid).where(:hidden=>0).order(:name).all
end