I haven't tried this (but I will need to this week). What I would do is spin up a new object to contain the original image, and then use open-uri to load the file data from the original into it. I found this bit of code on SO; I used it to transfer file data from CarrierWave to Paperclip already, so it's been tested to work:
(my has_attached_file is called blob, that's what blob means below)
def blob_url(url)
begin
require "open-uri"
f = open(url)
def f.original_filename ; base_uri.path.split('/').last ; end
self.blob = f
rescue OpenURI::HTTPError => e
raise(e) unless e.message == "404 Not Found"
ensure
f.close if f
end
end
So then you could do something like this:
@original = YourModel.find(original_id)
@copy = YourModel.new
@copy.blob_url(@original.blob.expiring_url)
@copy.save
That will fetch the original file data, and store it again in a new path for the new object. It's not particularly elegant, but given that you definitely don't want to just reference the same Paperclip storage object from two different AR objects (because one of them could be deleted, nuking the files for both) I believe it's the way forward here.
Walter
>
> Thanks,
> Avi
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to
rubyonra...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/63dfa195-e9aa-4884-9e44-d50958426641%40googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>