我收到以下错误:
[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无法处理或识别对象。
有没有人知道如何解决这个问题?
答案 0 :(得分:0)
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