Blogmark
ActiveSupport::CurrentAttributes
via jbranchaud@gmail.com
https://api.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html
Ruby on Rails
This can be used to house request-specific attributes needed across your application. A prime example of this is Current.user
as well as authorization details like Current.role
or Current.abilities
.
A word of caution: It’s easy to overdo a global singleton like Current and tangle your model as a result. Current should only be used for a few, top-level globals, like account, user, and request details. The attributes stuck in Current should be used by more or less all actions on all requests. If you start sticking controller-specific attributes in there, you’re going to create a mess.