Dreeub
Dreeub

Reputation: 396

How I can access the ActiveRecord Job after enqueuing a job

I want to access my ActiveRecord job item after enqueueing a task

job = MyCustomJob.perform_later 

Job is a MyCustomJob, but how I can access it without doing something like Delayed::Job.last?

Upvotes: 0

Views: 207

Answers (1)

Cristian Bica
Cristian Bica

Reputation: 4117

job.provider_job_id is the Delayed::Job's id so you could do Delayed::Job.find(job.provider_job_id).

Code is here: https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb#L20

Upvotes: 2

Related Questions