Class: Invite

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/invite.rb

Overview

An invitation, tracks the sender and recipient, and what the recipient is invited to. Generates a unique token for each invitation. The token is used in the invite url to (more) securely identify the invite when a new user clicks to register.

Instance Method Summary collapse

Instance Method Details

#check_recipient_existenceObject



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

def check_recipient_existence
  recipient = Invitation.configuration.user_model.find_by_email(email)
  self.recipient_id = recipient.id if recipient
end

#existing_user?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/models/invite.rb', line 24

def existing_user?
  recipient != nil
end

#generate_tokenObject



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

def generate_token
  self.token = SecureRandom.hex(20).encode('UTF-8')
end