0

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
coding addicted
  • 3,422
  • 2
  • 36
  • 47
  • May be this will helps you https://stackoverflow.com/questions/49409117/change-the-activestorage-controller-path – Hardik Upadhyay Apr 13 '18 at 06:42
  • @HardikUpadhyay thanks, sadly I see this question but in my case I don't want/need customs URL. I just want to mount active storage (which is an engine as far as understand) under a specific scope. – coding addicted Apr 13 '18 at 10:57

0 Answers0