Better globals with a tiny ActiveSupport module
In Rails, you might set data once during a request, but use it in every layer of your app. Which user is making the request? What permissions do they have? Using a Ruby global variable or class variable for this would be bad – multiple threads could overwrite it, and you’d end up with a huge mess. Instead, you need something that’s global, but for just that request.
Post a comment