Class: User

Inherits:
ApplicationRecord show all
Includes:
Discard::Model
Defined in:
app/models/user.rb

Overview

Represents an application user/respondent Users are linked to Alexa users using Alexa session request.user_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#==

Class Method Details

.authenticate(user_id) ⇒ Object


27
28
29
30
# File 'app/models/user.rb', line 27

def self.authenticate(user_id)
  user = User.find_or_create_by(username: user_id)
  user
end

Instance Method Details

#create_participantObject


32
33
34
# File 'app/models/user.rb', line 32

def create_participant
  self.participant ||= Participant.create!(user: self, email: '') if new_record?
end

#to_sObject


36
37
38
# File 'app/models/user.rb', line 36

def to_s
  username
end