in my user.rb i try save a link to avatar:
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.email = auth.info.email
user.password = Devise.friendly_token[0,20]
user.image = auth.info.image
end
it works with omniauth-google-oauth2 but with discord I get only half of image src. for example:
https://cdn.discordapp.com/avatars/714396517990037405/
where /714396517990037405/ is user id, image name is missing
This seems to be a bug on part of the omniauth-discord
gem. They concatenate the URL without checking whether an avatar is actually set.
But if you look at the Discord documentation, avatar
is actually of type ?string
so it can be null
.
General advice: if something isn't working and it's open source, take a look behind the scenes. Chances are you'll not only quickly find an explanation or solution but you'll also learn something about the things you're working with in the process.