aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Riley <tim@openmonkey.com>2014-07-29 09:58:13 +1000
committerTim Riley <tim@openmonkey.com>2014-07-29 09:58:13 +1000
commit21730dea6b5e5bb4bdb3420ae31238ee94925a0a (patch)
treeac3f4a9197be8df5b17a4e2014720b50e288d463
parent2c31b1832f440d0eb7c5db51d11630e885d0a824 (diff)
downloadrails-21730dea6b5e5bb4bdb3420ae31238ee94925a0a.tar.gz
rails-21730dea6b5e5bb4bdb3420ae31238ee94925a0a.tar.bz2
rails-21730dea6b5e5bb4bdb3420ae31238ee94925a0a.zip
Fix database serialization of job class names with Que
When passing a class constant as a job argument, Que’s stored procedures serialize it to JSON in the database as `{}`. This means that when the job (the ActiveJob “wrapper”) is deserialized from the database, it can’t find the original job class to run again. Changing the Que adapter to serialize the job class as a string fixes this behaviour. This change makes the adapter consistent with other adapters too (which constantize a class string in their JobWrapper#perform methods.
-rw-r--r--lib/active_job/queue_adapters/que_adapter.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/active_job/queue_adapters/que_adapter.rb b/lib/active_job/queue_adapters/que_adapter.rb
index 3d30b2bc72..4af3a0fbcf 100644
--- a/lib/active_job/queue_adapters/que_adapter.rb
+++ b/lib/active_job/queue_adapters/que_adapter.rb
@@ -5,7 +5,7 @@ module ActiveJob
class QueAdapter
class << self
def enqueue(job, *args)
- JobWrapper.enqueue job, *args, queue: job.queue_name
+ JobWrapper.enqueue job.to_s, *args, queue: job.queue_name
end
def enqueue_at(job, timestamp, *args)
@@ -15,7 +15,7 @@ module ActiveJob
class JobWrapper < Que::Job
def run(job, *args)
- job.new.execute *args
+ job.constantize.new.execute *args
end
end
end