Skip to content

Instantly share code, notes, and snippets.

@tiagogeraldi
Last active August 8, 2018 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagogeraldi/03436bc3c8baba3e42d8212f1f263f55 to your computer and use it in GitHub Desktop.
Save tiagogeraldi/03436bc3c8baba3e42d8212f1f263f55 to your computer and use it in GitHub Desktop.
Part of Apartment with no subdomain
require 'apartment/elevators/generic'
Apartment.configure do |config|
# Your Customer model
config.excluded_models = %w{ Customer }
# Customer name will be the key of the tenant
config.tenant_names = lambda { Customer.pluck :name }
end
Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda { |request|
request.session[:tenant] ? request.session[:tenant] : 'public'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment