mirror of
https://github.com/danbee/my-images
synced 2025-03-04 08:49:05 +00:00
20 lines
411 B
Ruby
20 lines
411 B
Ruby
class User < ActiveRecord::Base
|
|
dragonfly_accessor :avatar
|
|
|
|
has_many :images
|
|
|
|
def self.find_or_create_from_auth(auth)
|
|
find_by(auth.slice(:provider, :uid)) || create_from_auth(auth)
|
|
end
|
|
|
|
def self.create_from_auth(auth)
|
|
create(
|
|
provider: auth.provider,
|
|
uid: auth.uid,
|
|
username: auth.info.nickname,
|
|
name: auth.info.name,
|
|
avatar_url: auth.info.image,
|
|
)
|
|
end
|
|
end
|