Ask A Question

Notifications

You’re not receiving notifications from this thread.

ActsAsTenant demo app

Ole Torp asked in Rails

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.

Reply

From a senior dev...

  1. Have a tenant table that stores the domain
  2. Add tenant_id to devise users table for lookup
  3. 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!

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 84,387+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.