activerecord-multi-tenant
activerecord-multi-tenant copied to clipboard
Rails 7.1 - error when multi_tenant defined in abstract class
After updating to Rails 7.1, I'm getting this error when running my tests:
TypeError:
no implicit conversion of nil into String
I've tracked it down to this definition of multi_tenant in the parent abstract class:
I can confirm that MultiTenant.current_tenant is set. Moving the method directly to the subclass causes it to start working again. Removing the multi_tenant method will give me the expected invalid model (because the organization is nil).
I'm not seeing anything about this in the changelog... am I missing something?
Did you ever find a solution to this, other than moving multi_tenant to the subclasses?
@joshforbes @carldr I was also struggling with almost the same issue! Now I updated to Rails 7.1 by replacing the abstract class with a mix-in. The code is as follows:
module MultiTenantOrganization
extend ActiveSupport::Concern
included do
multi_tenant :organization
belongs_to :organization
end
end
class Account < ApplicationRecord # Previously, an abstract class was inherited here
include MultiTenantOrganization
# account implementation...
end