title: NoMethodError (undefined method `id' for nil:NilClass): in CarrierWave model
body: <p>I am using carrierwave to upload images in my rails project. This is my <code>uploader</code> class.</p>
  
  <pre><code>class ProfilePictureUploader &lt; CarrierWave::Uploader::Base
    def store_dir
      "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
    end
  end
  </code></pre>
  
  <p>I am <strong>not</strong> using <code>mount_uploader :avatar , ProfilePictureUploader</code> in my <code>model</code>. Instead I use this in my model</p>
  
  <pre><code>uploader = ProfilePictureUploader.new
  uploader.store!(file)
  self.image = uploader.url
  self.save
  </code></pre>
  
  <p>But this is giving me an error saying </p>
  
  <blockquote>
    <p>NoMethodError (undefined method `id' for nil:NilClass) </p>
  </blockquote>
  
  <p>Understandably the <code>model</code> instance is not available in <code>ProfilePictureUploader</code>. So <code>store_dir</code> method can't access <code>model.id</code>.  How can I get a similar directory structure with this flow.</p>
  
  <p>This is not a duplicate of <a href="https://stackoverflow.com/questions/18460686/carrierwave-file-hash-and-model-id-in-filename-store-dir">this problem</a> . For me , the <code>model</code> attribute of <code>uploader</code> is not available.</p>