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.
14 lines
290 B
Ruby
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
|