Files
grecia/lib/active_storage/service/tenant_disk_service.rb
Javi Martín edd47877c2 Extract methods to get tenant subfolder/file paths
We were using the same logic in many different places, so we're
simplifying the code. I'm not convinced about the method names, though,
so we might change them in the future.

Note using this method for the default tenant in the `TenantDiskService`
class resulted in a `//` in the path, which is probably harmless but
very ugly and it also generates a different key than the one we got
until now. I've added an extra test to make sure that isn't the case.
2022-11-11 01:41:14 +01:00

14 lines
290 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, Tenant.subfolder_path))
end
end
end
end