Class: User
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- User
- Defined in:
- app/models/user.rb
Class Method Summary collapse
Instance Method Summary collapse
- #active_for_authentication? ⇒ Boolean
- #email=(value) ⇒ Object
- #first_name ⇒ Object
- #full_name ⇒ Object
- #last_name ⇒ Object
- #queue_reminder_email ⇒ Object
- #send_devise_notification(notification, *args) ⇒ Object
Class Method Details
.from_omniauth(auth) ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/models/user.rb', line 43 def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create do |user| user.uid = auth.uid user.email = auth.info.email user.password = Devise.friendly_token[0, 20] end end |
.without_questionnaire ⇒ Object
51 52 53 |
# File 'app/models/user.rb', line 51 def self.without_questionnaire User.left_outer_joins(:questionnaire).where(questionnaires: { id: nil }, admin: false) end |
Instance Method Details
#active_for_authentication? ⇒ Boolean
10 11 12 |
# File 'app/models/user.rb', line 10 def active_for_authentication? true end |
#email=(value) ⇒ Object
24 25 26 |
# File 'app/models/user.rb', line 24 def email=(value) super value.try(:downcase) end |
#first_name ⇒ Object
28 29 30 31 |
# File 'app/models/user.rb', line 28 def first_name return "" if questionnaire.blank? questionnaire.first_name end |
#full_name ⇒ Object
38 39 40 41 |
# File 'app/models/user.rb', line 38 def full_name return "" if questionnaire.blank? questionnaire.full_name end |
#last_name ⇒ Object
33 34 35 36 |
# File 'app/models/user.rb', line 33 def last_name return "" if questionnaire.blank? questionnaire.last_name end |
#queue_reminder_email ⇒ Object
18 19 20 21 22 |
# File 'app/models/user.rb', line 18 def queue_reminder_email return if reminder_sent_at Mailer.delay_for(1.day).incomplete_reminder_email(id) update_attribute(:reminder_sent_at, Time.now) end |
#send_devise_notification(notification, *args) ⇒ Object
14 15 16 |
# File 'app/models/user.rb', line 14 def send_devise_notification(notification, *args) devise_mailer.send(notification, self, *args).deliver_later end |