Is it possible to make CarrierWave store, in the database, the full path of the uploaded files instead of just the file name and re-generate them every time they are accessed?
The reason why I want this is to be able to change the structure in which I store files without the already uploaded files disappearing until they are moved to their new locations.
My workaround is to store the directory on a separate attribute:
class MyModel
before_save do
self.content_path ||= "uploads/my_model/contents/#{id}"
end
end
Then your uploader will look like this:
class YourUploader < CarrierWave::Uploader::Base
...
def store_dir
model.content_path
end
...
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With