For those who have the same problem as me, this was my solution.
config / Initializers / apartment.rb
config.excluded_models = %w{ User }
Rails.application.config.middleware.use 'Apartment::Elevators::Generic', lambda { |request|
tenant_name = nil
if request.env['rack.session']['warden.user.user.key'] != nil
tenant_name = User.find(request.env['rack.session']['warden.user.user.key'][0][0]).account.name
end
return tenant_name
}
However, I'm not sure if this is 100% fault tolerance, so I will post updates if I find something wrong.
source
share