Files
grecia/lib/active_storage/service/tenant_disk_service.rb
Javi Martín 314ce70000 Use a different attachments folder per tenant
While this is not strictly necessary, it can help moving the data of one
tenant to a different server or removing it.

Note we're using subfolders inside the `tenants` subfolder. If we simply
used subfolders with the schema names, if the schema names were, for
instance, language codes like `es`, `en`, `it`, ... they would conflict
with the default subfolders used by Active Storage.
2022-11-11 01:39:19 +01:00

14 lines
301 B
Ruby

require "active_storage/service/disk_service"
module ActiveStorage
class Service::TenantDiskService < Service::DiskService
def path_for(key)
if Tenant.default?
super
else
super.sub(root, File.join(root, "tenants", Tenant.current_schema))
end
end
end
end