问题
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