0

I'm getting the following Error:

    [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'

While using these gems:

  • activeuuid
  • paperclip
  • delayed_job
  • delayed_paperclip

This is my actual model code:

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]

So I'm guessing the error is coming from activeuuid or delayed_paperclip as ActiveJob can't handle or recognize the Object.

Has anyone got an idea how to fix this?

1 Answers1

0

ActiveJob tries to serialize the arguments to be sent to the backend (sidekiq, dj, etc). Only JSON serializable objects are accepted plus GlobalIDs. The quickest solution for you is to pass your uuid as string and rebuild the uuid in your job.

# 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
Cristian Bica
  • 4,067
  • 27
  • 28
  • Thanks! I think this would work normally but I'm not building the Job myself, I use the delayed_paperclip gem for it. Might there be a chance of getting it to work with delayed_paperclip? I added my model above. – Thomas Klaiber Aug 20 '15 at 20:57
  • Got it. The issue is the combination between activeuuid and delayed_paperclip. I think an easy fix would be in delayed_paperclip (https://github.com/jrgifford/delayed_paperclip/blob/master/lib/delayed_paperclip.rb#L111) to use `.to_param` instead of `read_attribute(:id)`. You should file a bug in there. Also the fact that activeuuid returns a non-primitive type for the id column is not very nice :) – Cristian Bica Aug 21 '15 at 06:35
  • This solution worked for me, thanks a lot! I simply monkey patched the method. Although activeuuid is a real pain to use, it breaks so many gems, not going to use it in my next projects. – Thomas Klaiber Aug 21 '15 at 11:23