I'm using Sidekiq with CarrierWave and CarrierWaveBackgrounder to upload my images to S3 in the background. This works fine except for one thing: after I submit my form, the image gets enqueued in Sidekiq and processed, but the page reload happens faster than the background job, resulting in a 404 on the uploaded image. After another page refresh, the image usually shows up.
I'm wondering if there's a way to either show a tmp file (I have a image_tmp column in my database which seems to store a path to the file while it's processing/uploading), or reload my image after the processing is done.
I could poll my database for 'image_processing' to change to true, but that seems a bit like a waste of requests.
Relevant parts of my User class:
mount_uploader :profile_image, ProfileImageUploader
process_in_background :profile_image
store_in_background :profile_image
ProfileImageUploader includes Backgrounder
class ProfileImageUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::MiniMagick
My db has fields for profile_image_processing
and profile_image_tmp
, as well as, of course, a profile_image
column.