Question: ActiveJob: Accessible instance variables between callbacks

Question

ActiveJob: Accessible instance variables between callbacks

Answers 0
Added at 2016-12-19 19:12
Tags
Question

I have the following snippet within my job:

before_enqueue do |job|
  # do something
  @car = create_car
end


before_perform do |job|
  # do something
  @car.update(type: 'broken')
end

but when the job is performed @car is a nil. Is it possible to pass somehow the instance variable from one callback to the second one? Even only ID would be fine. Cheers.

Answers
Source Show
◀ Wstecz