You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using acts_as_tenant with an Account model for the tenant. I've got an acts_as_tenant.rb initializer containing
SET_TENANT_PROC=lambdadoifdefined?(Rails::Console)puts"> ActsAsTenant.current_tenant = Account.find_by!(name: 'Demo')"ActsAsTenant.current_tenant=Account.find_by!(name: 'Demo')endendActsAsTenant.configuredo |config|
config.require_tenant=lambdado
....end# Customize the query for loading the tenant in background jobsconfig.job_scope=->{all}endRails.application.configuredoifRails.env.development?# Set the tenant to the first account in development on loadconfig.after_initializedoSET_TENANT_PROC.callend# Reset the tenant after calling 'reload!' in the consoleActiveSupport::Reloader.to_completedoSET_TENANT_PROC.callendendend
It seems based on the log output that ActsAsTenant::Current is getting reset repeatedly during a reload!? The workaround seems fine to me, but maybe it indicates some problem in the gem, maybe worth updating the Readme at least.
I also tried to remove the to_complete block from the initializer, since I thought just configuring after_reset on console load would be enough, but it didn't work(maybe the class gets reset somehow and clears callbacks, not sure how CurrentAttributes works internally).
I did print ActsAsTenant.object_id and ActsAsTenant::Current.object_id and those do not change between reload!s so I don't think this is an issue of the constants themselves getting swapped out.
The text was updated successfully, but these errors were encountered:
Versions
Problem
I am using acts_as_tenant with an
Account
model for the tenant. I've got anacts_as_tenant.rb
initializer containingI think this matches the instructions in the Readme https://github.com/ErwinM/acts_as_tenant?tab=readme-ov-file#configuration-options
This works on initial console load, however after I run
reload!
in the consoleActsAsTenant.current_tenant
ends up being nil.If I change the proc to
Then it seems to work correctly after
reload!
as wellDiagnostic
It seems based on the log output that
ActsAsTenant::Current
is getting reset repeatedly during areload!
? The workaround seems fine to me, but maybe it indicates some problem in the gem, maybe worth updating the Readme at least.I also tried to remove the
to_complete
block from the initializer, since I thought just configuringafter_reset
on console load would be enough, but it didn't work(maybe the class gets reset somehow and clears callbacks, not sure how CurrentAttributes works internally).I did print
ActsAsTenant.object_id
andActsAsTenant::Current.object_id
and those do not change betweenreload!
s so I don't think this is an issue of the constants themselves getting swapped out.The text was updated successfully, but these errors were encountered: