I am using delayed_paperclip
and I have tried it with the default ActiveJob and it works well. However, it runs synchronously so it will wait for the job to finish before response so I wanted to move the queue to sidekiq.
But now that I have moved the queue to sidekiq, it gives me an error:
NoMethodError: undefined method `fetch' for nil:NilClass
I have tried looking for answers but I found no luck.
I added this to my application.rb
config.active_job.queue_adapter = :sidekiq
my Image model
has_attached_file :attachment,
styles: {
mini: '48x48#',
thumb: '75x95#',
tile: '212x212#',
tile_portrait: '230x327#',
large_tile: '300x300#',
small: '100x100#',
product: '240x240',
large: '360x460#',
large_portrait: '460x654#',
zoom_portrait: '690x981#'
},
process_in_background :attachment, processing_image_url: :processing_image_fallback
def processing_image_fallback
options = attachment.options
options[:interpolator].interpolate(options[:url], attachment, :original)
end
Does anyone know what the problem is? or is there a way that I can just use ActiveJob but how can I make it process the paperclip in the background?
Here is my image upload code also
def create_images
return if context.image == {}
context.images.each do |key, image|
new_image_record = Image.create(
kind: context.type
) #what I want to achieve: move on to next after creation
new_image_record.attachment = image
new_image_record.save #job runs here. hoping this will run in the background or be moved to sidekiq
end