ActsAsTenant demo app
I want to follow up on this post because I'm really interested in developing an application like Shopify that could be able to manage tenants pointing their own domains (not subdomains) to its accounts and wildcard them with the SSL to have HTTPS available.
From a senior dev...
- Have a tenant table that stores the domain
- Add tenant_id to devise users table for lookup
- In the application controller, match up devise's current_user object with the request.domain: https://github.com/ErwinM/acts_as_tenant#manually-using-before_action.
Allowing tenants to point to their own domains with subsequent SSL certificates is not Rails related. You probably already know there's no such thing as internet based wildcard root domain certs, and to be honest, I can't think of an intranet problem that solves either. So, you'll need to setup API access for domain registration (you choose) and automate cert generation to go with it, unless the domain registrar has that service (most do). Then call that code through normal view/controller actions.
There's not much to configure in Rails for SSL, https://guides.rubyonrails.org/configuring.html#config-ssl-options.
The domains will need set in Rails 7 config as explained here: https://guides.rubyonrails.org/configuring.html#configuring-middleware.
You'll have to restart your own Rails app for it to pick up the config changes because you can't really turn a rails app into a web host. 👀
This isn't going to work, but thanks for the chuckle. Hope you figure it out though!