.render blocks until the image is ready

One line does everything: new(cache).enqueue.wait

class Website::RenditionJob < ApplicationJob
  def self.render(page, consumer:)
    cache = page.caches
      .find_or_create_by_consumer!(consumer)
    return cache.rendition if cache.fresh?

    # 👇 Queue the job, block until it's done
    new(cache).enqueue.wait
    cache.reload.rendition
  end
end
16 / 45