That's an interesting problem, thank you for a very clear explanation. I think your idea of having two attachments is the right approach, because it seems they should indeed be treated separately. As I understood, the user first uploads the "master image", and afterwards they can edit? I'm assuming that the js-based image editor sends some kind of information to the server about which edits have been applied? I think I would do something like this:
class MasterUploader < Shrine
# ...
end
class AnnotatedUploader < Shrine
def process(io, context)
context[:record].annotations #=> annotations data
# processing logic
end
end
class Photo < ActiveRecord::Base
include MasterUploader[:master_image]
include AnnotatedUploader[:image]
attr_accessor :annotations
end
It might also be useful to make AnnotatedUploader a subclass of MasterUploader, depending on your situation. Then, after you've uploaded the master image, and you're handling the request for the annotated image, you could do:
# photo.annotations are assigned
photo.image = photo.master_image
This works because "photo.master_image" returns a Shrine::UploadedFile, which conforms to the IO interface needed for uploading.
Let me know if this helped :)
Janko