Row-level Multitenancy with ActsAsTenant Discussion
Of all the multi tenancy methods you have used, which one do you think is the best. I know it depends, but I need your opinion, which one would your mind start thinking of?
If it's not a healthcare app or where it's required that data needs to be separated then row based.
Honestly I don't even do pure row level tenancy most of the time, just query by top level account, company, etc. I only move to multi-tenant when clients require it or for white-labeled SAAS solutions.
Relative newbie here developing my first SaaS app and I"m struggling with the data model hierarchy. I'm expecting my customers will have 2-10 Users per Company. Currently I'll be manually onboarding customers, so I could have Users belong to a Company and create each Company and it's Users.
Seems counter to the typical model where User sits at the top, and also could be a problem if I move to self-serve signup down the road(though obviously I could create a dummy company until they fill in the info)
You can let people sign up using devise but accept a nested attribute for company and get the company name on the signup form as well. Company has many users and user belongs to company. Another thing is having a join table so
Company: has_many company_users
CompanyUser: belongs_to company, belongs_to user
User: has_many :company_users, belongs_to company, through: company_user
Thanks! To clarify, are you suggesting I create Company and User in the same form? I'm looking at blog posts like this for guidance: https://revs.runtime-revolution.com/saving-multiple-models-with-form-objects-and-transactions-2c26f37f7b9a.
Is that heading in the right direction?
To close this off, I couldn't get the above approach to work, and decided I don't really need it at this point, I can create Users and Companies from my admin dashboard.
I was able to get the model relations working, the only problem I encountered was I couldn't figure out how to bypass acts_as_tenant on my static(marketing) pages, so had to implement for each controller, which will work (just have to remember for new controllers!).