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

Multitenant object conflict. #259

Closed
abigoroth opened this issue Mar 3, 2021 · 2 comments
Closed

Multitenant object conflict. #259

abigoroth opened this issue Mar 3, 2021 · 2 comments

Comments

@abigoroth
Copy link

My application is using apartment gem and I am using postgresql schema as its tenant.
since the key is model_name:id:attribute I experience conflicts between tenants.

i've been eyeing on

def redis_prefix(klass = self) #:nodoc:
@redis_prefix ||= klass.name.to_s.
sub(%r{(.*::)}, '').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
downcase
end

maybe I can add something like
@redis_prefix = "#{Apartment::Tenant.current}:#{@redis_prefix}" if Object.const_defined?(Apartment::Tenant.to_s)
after

@nateware
Copy link
Owner

nateware commented Jun 8, 2021

This was a bug I introduced into the original version, since I reused code from Sinatra that improperly removed the fully-qualified class name. Sorry. Unfortunately I don't know how to fix it at this point, as any change to that method would change the keyname, meaning that it would result in innumerable bugs accessing keys that were named using the original methodology.

If anyone has any great ideas, I'm all ears.

@nateware
Copy link
Owner

Duplicate of #231

@nateware nateware marked this as a duplicate of #231 Jun 22, 2022
@nateware nateware closed this as not planned Won't fix, can't repro, duplicate, stale Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants