title: CarrierWave: detect if an image has already been uploaded
body: <p>A model is seeded with a remote url for an image, meaning the db entry it is not created in Rails. Then the first time it is fetched from the DB in Rails I want to detect that the image has not been uploaded, assign the remote_seed_url for the image url and save! to trigger the CarrierWave upload. I want to do this only once, obviously, but the code below sometimes uploads the same image more than once.</p>
  
  <pre><code>class Item
      include Mongoid::Document
      include Sunspot::Mongoid2
  
      field :image, type: String
      field :remote_seed_url, type: String #URL for image
      mount_uploader :image, ImageUploader 
  end
  </code></pre>
  
  <p>Then in a controller </p>
  
  <pre><code>def show
      @ item = Item.find(params[:id])
      # if CarrierWave has already uploded then do nothing
      if !@item.image?
          @item.image = @item.remote_seed_url # next save will trigger the upload?
          @item.save!
      end
      respond_to do ...
  end
  </code></pre>
  
  <p>The value of @item.image is usually "<em>new</em>" or "<em>old</em>" and @item.image? sometimes returns false when I can see that it has already uploaded the image. This causes the above code to upload multiple times.</p>
  
  <ol>
  <li>Is the controller code correct to get the image uploaded only once? </li>
  <li>Is there some way I might have messed things up and caused @item.image? to return false when it should be true? Maybe image aging?</li>
  </ol>