26

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

Sergiy Seletskyy
  • 16,236
  • 7
  • 69
  • 80

1 Answers1

50

Apartment::Tenant.current

P. S. Thank you @pa-buisson

Sergiy Seletskyy
  • 16,236
  • 7
  • 69
  • 80
  • 3
    Beware, ``Apartment::Database`` seems to be deprecated now. Instead, you can now use ``Apartment::Tenant.current``. – Pierre-Adrien Nov 06 '14 at 11:07
  • Is possible that current is returning always public? – halbano Jun 01 '17 at 20:27
  • 2
    Note that this returns a `String` with the current subdomain, not a `Tenant` object. – Cimm Apr 16 '20 at 13:07
  • @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) ?? – Ronats Dec 05 '22 at 07:46
  • @Ronats thank you for your question. Unfortunately, I cannot help you now. 8 years have passed since I had been working with that domain. – Sergiy Seletskyy Dec 28 '22 at 14:28