-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Replace RequestStore dependency with CurrentAttributes #313
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but the gemfile.lock files have to reflect this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
Great idea. Is it possible to go farther? I am considering to get rid of the classic “current_user” and “current_tenant” methods in my code and to introduce my own Current class instead. I thinks such an would reduce even more complexities at this gem. However, everyone would be forced to set this up themselves, when they use the gem and acts_as_tenant would need to know the name of the Current class the individual app uses and how the attributes are called… |
Users of acts_as_tenant would still use |
I just wrote my own version of this several months later for the same reason (we finally got around to moving our Rails app over from RequestStore). In particular, if you're using AAT & CurrentAttributes, the reset behaviour in test mode isn't the same and this was actually giving us compatibility headaches. I'd really like to see this merged ASAP! In the mean time I'm monkey patching @excid3 One note - you don't need your inner |
🎉 Thank you! 😄 |
This simplifies ActsAsTenant by dropping the RequestStore dependency. We can use Rails' built-in CurrentAttributes feature that accomplishes the same thing.
CurrentAttributes was introduced in Rails 5.2 and we already require 5.2 or higher, so this should not be a breaking change. While this should be a drop-in replacement, it'd be nice to have this tested in several applications before releasing the change. If you have a chance to test this in your application(s), please do!
The only minor gripe I know of is that CurrentAttributes doesn't play well with the web-console gem because those requests are not in the same thread.