Dead simple multi-tenancy in Rails.

ยท

1 min read

I think Kolide has nailed it with this post. Effectively they define a concern which associates a model to an account (organization, company, or whatever model defines your tenant) and sets the default scope of the model to find the current user's account provided and defined by ActiveSupport::CurrentAttributes.

I'll certainly be considering this approach the next time I'm tasked with implementing a multi-tenant Rails application.

ย