Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multitenancy without subdomains

It seems like most of the documentation / tutorials that I’ve found about multi-tenanted apps seem to prefer scoping via a subdomain. The old classic-style basecamp probably set the presendent for this, where each user / company would have a http://mycompany.app.com address. Apps like Harvest, for example, also do this.

I recently noticed that the new basecamp no longer has company subdomains...

Just wondering what the advantages of scoping through a subdomain are vs. say, scoping the User’s data through a gem like Pundit or CanCan?

like image 847
andrewmarkle Avatar asked Nov 18 '25 03:11

andrewmarkle


1 Answers

Using Pundit or CanCan (CanCanCan) is more for roles/authorization of what a user(non-admin) can do in the application.

Mutlitenancy using subdomains without separate schemas just gives a unique account_id in your tables where as if you use postgres schemas it creates a separate schema for each subdomain(account); so each subdomain/account has their own copy of the tables..

You can also have multitenancy not using subdomains by using a gem such as https://github.com/dsaronin/milia

There are pros and cons for each. Also checkout this video: http://confreaks.com/videos/111-aac2009-writing-multi-tenant-applications-in-rails

like image 74
tabishiqbal Avatar answered Nov 20 '25 18:11

tabishiqbal