Skip to content

Instantly share code, notes, and snippets.

@leomao10
Last active July 10, 2019 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leomao10/a26d46451dac095c38432f383ab7535b to your computer and use it in GitHub Desktop.
Save leomao10/a26d46451dac095c38432f383ab7535b to your computer and use it in GitHub Desktop.
ActiveSupport::CurentAttributes surprise
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