How to get current tenant when using Appartment gem in multi-tenancy Rails 4
Asked Answered
L

1

26

How can I find out which tenant (schema) is the current one when Apartment was initialized according to request

Limoges answered 23/7, 2014 at 12:17 Comment(0)
L
50

Apartment::Tenant.current

P. S. Thank you @pa-buisson

Limoges answered 23/7, 2014 at 12:17 Comment(5)
Beware, Apartment::Database seems to be deprecated now. Instead, you can now use Apartment::Tenant.current.Beryllium
Is possible that current is returning always public?Diazo
Note that this returns a String with the current subdomain, not a Tenant object.Fearsome
@Sergiy Seleskyy Is it is possible to get Tenant based on a given record. For example user1 is in tenent1 and user2 is in tenent2. How can I find Tenent of user1 Apartment::Tenant.current(user1) ??North
@North thank you for your question. Unfortunately, I cannot help you now. 8 years have passed since I had been working with that domain.Limoges

© 2022 - 2024 — McMap. All rights reserved.