Skip to content

Commit

Permalink
update how we set User.current
Browse files Browse the repository at this point in the history
  • Loading branch information
vasconsaurus committed Sep 12, 2024
1 parent 3cd9a14 commit bf6686a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/workers/generic_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ def perform(klass_name, klass_method, *method_args)
klass = klass_name.constantize
options = method_args.extract_options!.with_indifferent_access
if options
if options.key?(:user_id)
user_id = options.delete(:user_id)
User.current = User.find_by_id(user_id)
end
user_id = options.delete(:user_id) if options.key?(:user_id)
current_user = User.current
User.current = User.find_by_id(user_id)
klass.public_send(klass_method, **options)
User.current = nil
User.current = current_user
else
klass.public_send(klass_method)
end
Expand Down

0 comments on commit bf6686a

Please sign in to comment.