Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

shadysayed's Profile

GitHub User: shadysayed

Comments by


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)! # 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?