Sha256: e8c2b9bb7c8d568bf9c8f39bb607daa9362bb0f7d5463ca3bc1e8d71a1b817ff

Contents?: true

Size: 1.27 KB

Versions: 19

Compression:

Stored size: 1.27 KB

Contents

class User < ApplicationRecord
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,
         :omniauthable, omniauth_providers: [:mlh]

  has_one :questionnaire

  def active_for_authentication?
    true
  end

  def send_devise_notification(notification, *args)
    devise_mailer.send(notification, self, *args).deliver_later
  end

  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

  def email=(value)
    super value.try(:downcase)
  end

  def first_name
    return "" if questionnaire.blank?
    questionnaire.first_name
  end

  def last_name
    return "" if questionnaire.blank?
    questionnaire.last_name
  end

  def full_name
    return "" if questionnaire.blank?
    questionnaire.full_name
  end

  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

  def self.without_questionnaire
    User.left_outer_joins(:questionnaire).where(questionnaires: { id: nil }, admin: false)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
hackathon_manager-0.5.7 app/models/user.rb
hackathon_manager-0.5.6 app/models/user.rb
hackathon_manager-0.5.5 app/models/user.rb
hackathon_manager-0.5.4 app/models/user.rb
hackathon_manager-0.5.3 app/models/user.rb
hackathon_manager-0.5.2 app/models/user.rb
hackathon_manager-0.5.1 app/models/user.rb
hackathon_manager-0.5.0 app/models/user.rb
hackathon_manager-0.4.4 app/models/user.rb
hackathon_manager-0.4.3 app/models/user.rb
hackathon_manager-0.4.2 app/models/user.rb
hackathon_manager-0.4.1 app/models/user.rb
hackathon_manager-0.4.0 app/models/user.rb
hackathon_manager-0.3.3 app/models/user.rb
hackathon_manager-0.3.2 app/models/user.rb
hackathon_manager-0.3.1 app/models/user.rb
hackathon_manager-0.3.0 app/models/user.rb
hackathon_manager-0.2.0 app/models/user.rb
hackathon_manager-0.1.0 app/models/user.rb