Last active
July 10, 2019 08:38
-
-
Save leomao10/a26d46451dac095c38432f383ab7535b to your computer and use it in GitHub Desktop.
ActiveSupport::CurentAttributes surprise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JwtCurrent < ActiveSupport::CurrentAttributes | |
attribute :jwt | |
end | |
# in api_controller.rb | |
def some_action | |
JwtCurrent.jwt = "something" | |
future = Concurrent::Future.execute do | |
puts "*" * 50 | |
puts JwtCurrent.jwt #=> nil | |
puts "*" * 50 | |
end | |
result = future.value | |
render json: result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment