Why CarrierWave image is not duplicated the second time?

南楼画角 提交于 2019-12-13 04:53:11

问题


I try to duplicate a record many time using this code :

my_obj = Obj.find_by(id: params[:id])
new_obj = my_obj.dup

I use CarrierWave to mount an image to my Obj

class Obj < ActiveRecord::Base
   mount_uploader :image, ObjImageUploader
end

my first code above, duplicate the obj as well but it doesn't duplicate the image correctly, it shows instead something like Medium 2013 08 04 14354, so i tried to fix this using

new_obj = my_obj.dup
new_obj.image = my_obj.image

and now it works correctly, the image is shown as well

if i try to duplicate the duplicated new_obj itself

another_obj = new_obj.dup
another_obj.image = new_obj.image

it shows me again Medium 2013 08 04 14354...

so i get this if i copy a copied image, then when i search for the created folder with image there is no folder/image created

What's going wrong here ?

来源:https://stackoverflow.com/questions/20869646/why-carrierwave-image-is-not-duplicated-the-second-time

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