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

泪湿孤枕 提交于 2019-12-10 10:25:02

问题


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

回答1:


Have you tried this?

In your method, change the line

user.avatar = auth.info.image

to

user.remote_avatar_url = auth.info.image


来源:https://stackoverflow.com/questions/19868830/devise-omniauth-carrierwave-doesnt-save-facebook-profile-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!