ActiveJob::SerializationError 使用 ActiveUUID

ActiveJob::SerializationError with ActiveUUID

我收到以下错误:

    [ActiveJob] Enqueued DelayedPaperclip::Jobs::ActiveJob (Job ID: 78975c5c-7da2-4a70-a156-91cda1c53013) to DelayedJob(paperclip) with arguments: "Video", #<UUID:0x3fc83523c368 UUID:b543e798-ad01-4416-b8fb-9ddb0d31a6ce>, "video"
Completed 500 Internal Server Error in 96195ms (ActiveRecord: 1.5ms)

ActiveJob::SerializationError (Unsupported argument type: UUIDTools::UUID):
  app/controllers/video_controller.rb:11:in `create'

使用这些宝石时:

这是我的实际模型代码:

class Video < ActiveRecord::Base
  include ActiveUUID::UUID

  belongs_to :timeline
  has_attached_file :video,
                    :styles => {
                        :thumb => { :geometry => "360x360#", :format => 'jpg', :time => 1 },
                        :lowres => { :geometry => "360x360#", :format => 'mp4' }
                    }, only_process: [:thumb], :processors => [:transcoder],
                    :path => ":class/:id/:style/:basename.:extension"

  validates_attachment_content_type :video, :content_type => ["video/mp4", "video/mov", "video/mpeg","video/mpeg4", "video/quicktime", "image/jpg", "image/jpeg"]

  process_in_background :video, only_process: [:lowres]

所以我猜测错误来自 activeuuid 或 delayed_paperclip,因为 ActiveJob 无法处理或识别对象。

有没有人知道如何解决这个问题?

ActiveJob 尝试序列化要发送到后端的参数(sidekiq、dj 等)。仅接受 JSON 个可序列化对象以及 GlobalID。最快的解决方案是将您的 uuid 作为字符串传递并在您的工作中重建 uuid。

# enqueue
VideoJob.perform_later uuid.to_s
# job class
class VideoJob
  def perform(uuid_string)
    uuid = UUIDTools::UUID.parse(uuid_string)
    # do whatever you need to do
  end
end