RailsCasts Pro episodes are now free!

Learn more or hide this

Shady Sayed's Profile

GitHub User: shadysayed

Comments by Shady Sayed


Great episode thx a lot.
I noticed something strange though. you create thumbnails based on the presence of the key attribute in the Painting class on the after_save

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

but then you also set the key attribute in the perform method of the background task

    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.save! # enqueue_image will get called again
      painting.update_column(:image_processed, true)

I think this will result in putting another message in the background queue. which will always keep your worker busy recreating thumbnails. Am I correct?