steveklabnik / request_store

Per-request global storage for Rack.
https://github.com/steveklabnik/request_store
MIT License
1.47k stars 87 forks source link

Does Rails (5.2+) ActiveSupport::CurrentAttributes have same functionality as this gem? #85

Open eoinkelly opened 2 years ago

eoinkelly commented 2 years ago

It seems like Rails' built-in (since 5.2) ActiveSupport::CurrentAttributes has the same functionality as this gem.

If my reading is correct then I think we should add a note to the README explaining this and perhaps encouraging using that instead. If I'm wrong then a note explaining the difference would be equally useful.

steveklabnik commented 2 years ago

I haven't used Rails since Rails 4, if anyone knows this answer, I would be happy to take a PR explaining it.

alexeyr-ci commented 1 year ago

E.g. I use RequestStore to make sure a <script> tag only gets inserted once even if a partial which includes it is rendered several times. It very much doesn't fall under

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.