Module: DeviseHelper

Defined in:
app/helpers/devise_helper.rb

Instance Method Summary collapse

Instance Method Details

#devise_error_messages!Object

override to make formatting more friendly


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/devise_helper.rb', line 15

def devise_error_messages!

  return "" if resource.errors.empty?
  
  messages = resource.errors.full_messages.map { |msg| (:li, msg) }.join
  alert_class = 'alert-error'

  # trap Twitter email missing error - need friendler message
  if resource.provider == 'twitter' && resource.email.empty?
    messages = (:li, t(:twitter_email_needed, scope: :'myinfo.devise.messages'))
    alert_class = 'alert-info'
  end

  # empty out error messages so they don't linger
  resource.errors.clear  
  
  # remove close button option for now - CSS conflict with facebox
  html = <<-HTML
<div class="alert fade in #{alert_class}">
<ul>#{messages}</ul>
</div>
HTML
  html.html_safe
end

#devise_mappingObject


10
11
12
# File 'app/helpers/devise_helper.rb', line 10

def devise_mapping
  @devise_mapping ||= Devise.mappings[:user]
end

#resourceObject


7
8
9
# File 'app/helpers/devise_helper.rb', line 7

def resource
  @resource ||= User.new
end

#resource_nameObject

allow for flexible location of Devise forms


4
5
6
# File 'app/helpers/devise_helper.rb', line 4

def resource_name
  :user
end