Can a User in your multi-tenant app use more than one subdomain? If the answer is no then do you have a relationship between User & Account or User & Subdomain, if yes then you can switch the tenant context based to the subdomain assigned to the user. No ?
How about using ActsAsTenant multi-tenancy gem which stores tenant context in the current thread and using ActsAsTenant.current_tenant = request.subdomain in Connection you should be able to access ActsAsTenant.current_tenant is Connection.
May be I am missing something here ... so let me know if I am wrong.
Can a User in your multi-tenant app use more than one subdomain? If the answer is no then do you have a relationship between User & Account or User & Subdomain, if yes then you can switch the tenant context based to the subdomain assigned to the user. No ?
How about using ActsAsTenant multi-tenancy gem which stores tenant context in the current thread and using ActsAsTenant.current_tenant = request.subdomain in Connection you should be able to access ActsAsTenant.current_tenant is Connection.
May be I am missing something here ... so let me know if I am wrong.
That's exactly what I thought. It should definitely work.
See github.com/rails/rails/issues/27875