Ask A Question

Notifications

You’re not receiving notifications from this thread.

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?

Reply

If it's not a healthcare app or where it's required that data needs to be separated then row based.

Reply

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.

Reply

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)
Any advice?

Reply

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

Reply

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?

Reply

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!).

Reply

Late to the party and wondering if ActsAsTenant would work in the following scenario and how.

Basically, I have a company that has a many products, which are marketed to three verticals (consumer, commercial and industrial). All products are available to each vertical but have different a separate presentation for each (copy emphasizing appropriate features, custom photos, videos, brochure files, etc.).

The consumer vertical is default and is not available only on main domain (no subdomain for it). The commercial and industrial are only available on their subdomains (this will apply to any other specific verticals that will be added in the future).

In addition to this, there needs to be an admin area on a subdomain that would provide authorized users with access to all product presentations for all verticals.

The standard way I would approach this would require some code updates for each new vertical and I wondered if this could be better handled using ActsAsTenant given the scenario I outlined above (only the admin area/subdomain requires authentication, everything else would be publicly available).

Thanks in advance for any feedback.

Reply

Hey Chris/Team, Are there any videos on Gorails that shows how we can implement a custom domain feature into our multitenant app? More specifically can we do these sort of DNS changes and routing in Hatchbox? I use Heroku for apps but am ready to jump my apps over to Hatchbox as it looks and sounds much better. I'm building a multi-tenant app here and would really love to be able to mask a user's own domain in place of an account-level domain within the app. Any helps would be appreciated.
Thanks a million.

Reply
Join the discussion
Create an account Log in

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

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

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