A multi tenants app living on a subdomain give those kind of urls to tenants:
subdomain.domain.com/:tenant-id/the-route-you-want
All tenants have their own postgresql schema.
Uploading with Active Storage works fine and the good schema got populated but when you try to get the file the url is not referencing the tenant id anymore because Active Storage has its own routes.
Is their a way to scope those routes?
Using apartment gem, my actual work around is to pass the tenant id to the default url:
class ApplicationController < ActionController::Base
def default_url_options(options = {})
{ tenant: params[:tenant]}
end
end
And to tweak the Apartment initializer:
tenant = req.params['tenant'] || req.path.split('/')[1]
Is their a way to make Active Storage URL under the good scope? Something like:
scope path: ":tenant" do
mount-active-storage-paths
end