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?

Reply

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

Reply

Thanks a ton. Let me try and implement this.

Reply

It worked!

Reply
Join the discussion
Create an account Log in

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

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

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