Class: User

Inherits:
ApplicationRecord show all
Defined in:
lib/app/models/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_omniauth(access_token) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/app/models/user.rb', line 19

def self.from_omniauth(access_token)
  user = User.find_by(email: access_token.info.email)
  unless user
    user = User.create(
      email: access_token.info.email,
      password: Devise.friendly_token[0,20]
    )
  end
  user.first_name = access_token.info.first_name
  user.last_name = access_token.info.last_name
  user.image = access_token.info.image
  # user.uid = access_token.uid
  # user.provider = access_token.provider
  user.save

  user
end

Instance Method Details

#full_nameObject



8
9
10
# File 'lib/app/models/user.rb', line 8

def full_name
  "#{first_name} #{last_name}"
end