RailsCasts Pro episodes are now free!

Learn more or hide this

Kai Schlichting's Profile

GitHub User: lacco

Comments by Kai Schlichting


If you are using the Dalli memcached gem, it is able to store binary data by using Rails.cache.fetch("foo", raw: true){Time.now}.

Btw, why do you want to cache it on server-side instead of delivering the S3 URL to the client? If the file is private, then you could use an authenticated URL with expiration


I played around with this issue, and the only solution that worked for me was adding an explicit flag to skip the processing:

  def enqueue_image
    ImageWorker.perform_async(id, key) if key.present? && !skip_image_processing

  def perform(id, key)
    painting = Painting.find(id)
    painting.key = key #setting the key again
    painting.remote_image_url = painting.image.direct_fog_url(with_path: true)
    painting.skip_image_processing = true
    painting.save! # enqueue_image will get called again
    painting.update_column(:image_processed, true)

Any other, more elegant ideas?