CarrierWave how to store file at given url

前端 未结 3 1271
春和景丽
春和景丽 2020-12-25 13:44

I have CarrierWave working fine through the typical ORM setup and upload via form. I would like to figure out how to use CarrierWave outside of the form submission context.

3条回答
  •  醉梦人生
    2020-12-25 14:10

    in the controller after user sign up (assuming your user image field is called simply 'image')

    gravatar_url = "http://www.gravatar.com/avatar/#{Digest::MD5.new.update(current_user.email)}?s=512&d=identicon"
    @user.remote_image_url = gravatar_url
    @user.save 
    

    i think this is the best way according to carrierwave docs and some searching around.

    enjoy!

提交回复
热议问题