All threads / Disabling a tenant in a Multi-tenancy Saas app with apartment

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Disabling a tenant in a Multi-tenancy Saas app with apartment

kshitijLohbare asked in Rails

Hey everyone, I was launching a multi-tenant app and want to know if there is a way through which we can disable a tenant if they cancel the subscription without deleting their data.
I can add this in the routes.rb file -

--
class SubdomainConstraint
def self.matches?(request)
subdomains = %w{ www admin homes }
request.subdomain.present? && !subdomains.include?(request.subdomain)
end
end
Rails.application.routes.draw do
constraints SubdomainConstraint do
resources :companies
end

But then is there another way to add more names in that constraint without having to deploy the code everytime.
Do you have suggestions?

I would just put a before_action on all the controllers that directs away if they aren't subscribed. Nice and simple.

Thanks a ton. Let me try and implement this.

Join the discussion

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.