Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7.1 - error when multi_tenant defined in abstract class #230

Open
joshforbes opened this issue Feb 26, 2024 · 2 comments
Open

Rails 7.1 - error when multi_tenant defined in abstract class #230

joshforbes opened this issue Feb 26, 2024 · 2 comments

Comments

@joshforbes
Copy link

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:

image

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?

@carldr
Copy link

carldr commented Jun 14, 2024

Did you ever find a solution to this, other than moving multi_tenant to the subclasses?

@dlwr
Copy link
Contributor

dlwr commented Jul 5, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants