title: Image upload in ruby with sinatra and datamapper and Carrierwave?
body: <p>I want to upload a single image with Carrierwave, the thing is, it is uploading the file and saving it into the directory uploads, in this folder it creates another folder called tmp, and in the tmp folder it creates another folder which includes the image. 
  The thing is it doesn't seem to stop it is uploading and uploading and uploading all the time even if the image is fully uploaded into that folder and I can open this image already with feh(or anyother image viewer).</p>
  
  <p>This is what my controller looks like.</p>
  
  <pre><code>get "/new" do
      protect!
  
      erb :new
  end
  
  post "/new" do
      protect!
  
      @user = User.get(session[:user_id])
      image = @user.image.new(
          :description =&gt; params[:description],
          :image =&gt; params[:image]
      )
  
      # image.save
  
      "NEVER REACHED!"
  
  end
  </code></pre>
  
  <p>(The text "NEVER REACHED!" won't be displayed at all and I don't know why...)</p>
  
  <p>This is my model:</p>
  
  <pre><code>class ImageUploader &lt; CarrierWave::Uploader::Base
      def extensions_white_list
          %w(jpg jpeg gif png)
      end
  
      storage :file
  end
  
  class Image
      include DataMapper::Resource
  
      property :id, Serial
      property :description, Text
  
      property :image, String, :auto_validation =&gt; false
      mount_uploader :image, ImageUploader
  end
  
  class User
      include DataMapper::Resource
  
      property :id, Serial
  
      has n, :post
  end
  </code></pre>
  
  <p>So as already mentioned the Text "NEVER REACHED" is never reached. Any Ideas why?</p>
  
  <p>Besides I always get the warning: </p>
  
  <pre><code>Defining property for an uploader is deprecated at /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  </code></pre>
  
  <p>And I do not know why...</p>
  
  <p><strong>UPDATE:</strong> It is somehow working now as long as I do not uncomment image.save in the main controller, but I actually need to uncomment this, any Ideas how to fix this?</p>