Reputation: 3032
I built my Rails app and figured I would use Active Storage (AS). I then realized that AS dumps all your files into your storage root. I need to segregate that between clients and also I would rather organize these on a model basis etc. Carrierwave (CW) can do this out of the box. I am going to build a rake task to migrate these old attachments over.
The AS blob key is the filename stored locally except on my local machine its stored like this:
/storage/HR/mw/HRmWZZNk4wd7dD1nt9iUbi1n
and on my S3 compatible store:
/HRmWZZNk4wd7dD1nt9iUbi1n
There seems to be no built-in method to return the local path of an AS file (which CW has). I know I can on the fly build the local path but looking to see if I am missing something obvious here.
Upvotes: 2
Views: 5018
Reputation: 3032
Found it here:
Get path to ActiveStorage file on disk
ActiveStorage::Blob.service.send(:path_for, user.avatar.key)
Upvotes: 4