Dead simple multi-tenancy in Rails.

Andy KochAndy Koch
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.

0
Subscribe to my newsletter

Read articles from Andy Koch directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Andy Koch
Andy Koch

๐Ÿš€ Experienced Full Stack Developer with more than 12 years of professional experience with Ruby on Rails and related technology. I've built products from the ground up for startups and I've jumped in on existing code bases to add features and solve problems in a timely and cost effective manner. I understand the value of a solid test suite. I also have extensive experience with Vue.js - I've built mobile applications and complex front-end solutions for Rails using Vue. I'm a seasoned remote worker - I've been working remote since 2000.