ruby - Referencing delayed_job job id from within the job task -


i've got delayed_job task spits out file. i'd able prefix file id of job created it, reference later on.

# create file has job id in name... job_id = thing.delay.create_file # we'll use job_id search file... 

is possible?

let's take here...

class writefilejob   attr_accessor :dj_id, :file_name    def initialize(file_name)     @file_name = file_name   end    def perform     # @dj_id; don't worry, we'll set below   end end 

now when enqueue job, should job back:

j = delayed::job.enqueue(writefilejob.new("foo.txt")) 

next, load object enqueued, , updated id got back:

object_to_update = yaml.load(j.handler) object_to_update.dj_id = j.id # update handler j.handler = object_to_update.to_yaml j.save 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -