I need help figuring out how to get CarrierWave to work with an ActiveResource object. I am working on a project that currently uses CarrierWave on a standard ActiveRecord object which works very nicely. However, we are migrating toward a remote file system so I need CarrierWave to work with ActiveResource objects.
I know that CarrierWave allows you to write your own storage engine rather than use say fog, file, or mongo grid_fs but I can't figure out what the flow for this process is.
Here is the state of my efforts:
ReportDocument class
class ReportDocument
mount_uploader :merchant_geoip_image, ImageUploader
end
Uploader for CarrierWave
class ImageUploader < CarrierWave::Uploader::Base
storage MyCustomStorageEngine
end
My custom storage engine
class MyCustomStorageEngine
def store!(file)
# do custom storage stuff with ActiveResource object here
end
def retrieve!(identifier)
# do custom retrieval stuff with ActiveResource object here
end
end
My issue is that I can't get CarrierWave to call my custom store!
and retrieve!
methods when I save the ReportDocument
object. The Mongoid ORM defines their storage engine as gridFS
which can be found here: https://github.com/carrierwaveuploader/carrierwave-mongoid/blob/master/lib/carrierwave/storage/grid_fs.rb
It doesn't seem like I'm doing anything different from the Mongoid ORM implementation. Any help would be greatly appreciated.