Uploading a remote file url from Rails Console with Carrierwave

后端 未结 5 713
不思量自难忘°
不思量自难忘° 2020-12-25 10:46

I just wanted to know how one would go about uploading a remote file url using Carrierwave in the Rails console.

I tried the following without any luck. I presume it

5条回答
  •  没有蜡笔的小新
    2020-12-25 11:21

    user = User.first
    user.remote_avatar = File.open(FILE_LOCATION)
    user.save
    

    FILE_LOCATION can be

    File.join(Rails.root, '/files/png-sample.png')
    

    if file is found in a folder 'files' in rails project

提交回复
热议问题