Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何使用回形针复制文件_Ruby On Rails_Paperclip_Copying - Fatal编程技术网

Ruby on rails 如何使用回形针复制文件

Ruby on rails 如何使用回形针复制文件,ruby-on-rails,paperclip,copying,Ruby On Rails,Paperclip,Copying,有人知道用S3存储的回形针复制文件的方法吗?在我尝试写我自己的之前,我只是想确定没有一种方法可以做到这一点。谢谢在用回形针胡闹了一会儿之后,我终于明白了。复制文件非常简单 # Stupid example method that just copies a user's profile pic to another user. def copy_profile_picture(user_1, user_2) user_2.picture = user_1.picture user_2.s

有人知道用S3存储的回形针复制文件的方法吗?在我尝试写我自己的之前,我只是想确定没有一种方法可以做到这一点。谢谢

在用回形针胡闹了一会儿之后,我终于明白了。复制文件非常简单

# Stupid example method that just copies a user's profile pic to another user.
def copy_profile_picture(user_1, user_2)
  user_2.picture = user_1.picture
  user_2.save # Copied the picture and we're done!
end

这也适用于AmazonS3。Sweet

不过,这里的问题是,如果您有任何媒体编辑或删除,当用户1编辑或删除他们的图片时,用户2会在他们的个人资料中得到这些更改,对吗?