Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devise + omniauth + carrierwave doesn't save facebook profile image

I am using devise with omniauth facebook. I upload avatars for people that are not signing in with facebook with carrierwave, with the AvatarUploader.

But when I try fetching the avatar from the facebook user, it does not save - user.avatar = auth.info.image does not save, and after signing in equals nil.

Why is that and how can I fix it? Thanks in advance.

  def self.from_omniauth(auth)
    where(auth.slice(:provider, :uid)).first_or_create do |user|
      user.provider = auth.provider
      user.uid = auth.uid
      user.email = auth.info.email
      user.avatar = auth.info.image
    end
  end
like image 675
figdig Avatar asked Nov 22 '25 11:11

figdig


1 Answers

Have you tried this?

In your method, change the line

user.avatar = auth.info.image

to

user.remote_avatar_url = auth.info.image
like image 154
Ashitaka Avatar answered Nov 24 '25 07:11

Ashitaka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!