Use a custom method to detect the current tenant

The subdomain elevator we were using, which is included in apartment,
didn't work on hosts already including a subdomain (like
demo.consul.dev, for instance). In those cases, we would manually add
the subdomain to the list of excluded subdomains. Since these subdomains
will be different for different CONSUL installations, it meant each
installation had to customize the code. Furthermore, existing
installations using subdomains would stop working.

So we're using a custom method to find the current tenant, based on the
host defined in `default_url_options`.

In order to avoid any side-effects on single-tenant applications, we're
adding a new configuration option to enable multitenancy

We're enabling two ways to handle this configuration option:

a) Change the application_custom.rb file, which is under version control
b) Change the secrets.yml file, which is not under version control

This way people prefering to handle configuration options through
version control can do so, while people who prefer handling
configuration options through te secrets.yml file can do so as well.

We're also disabling the super-annoying warnings mentioning there are no
tenants which we got every time we run migrations on single-tenant
applications. These messages will only be enabled when the multitenancy
feature is enabled too. For this reason, we're also disabling the
multitenancy feature in the development environment by default.
This commit is contained in:
Javi Martín
2022-09-30 23:24:34 +02:00
parent d77cf77761
commit 5983006657
6 changed files with 167 additions and 8 deletions

View File

@@ -59,6 +59,9 @@ Rails.application.configure do
Bullet.raise = true # raise an error if n+1 query occurs
end
end
# Allow managing different tenants using the same application
config.multitenancy = true
end
require Rails.root.join("config", "environments", "custom", "test")