Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

ActiveSupport::Notifications and Thread.current

More than 3 years have passed since last update.

http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html

http://railscasts.com/episodes/249-notifications-in-rails-3

http://web.archive.org/web/20150515174238/http://m.onkey.org/thread-safety-for-your-rails

https://github.com/rails/rails/blob/master/activesupport/lib/active_support/per_thread_registry.rb

https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications.rb#L205-L208

https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications.rb#L185-L188

https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications.rb#L164

https://github.com/steveklabnik/request_store

class RequestRegistry
  extend ActiveSupport::PerThreadRegistry

  attr_accessor :current_user, :current_permissions
end

RequestRegistry.current_user = "user"
puts RequestRegistry.current_user

http://www.justinweiss.com/articles/better-globals-with-a-tiny-activesupport-module/

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away