title: Manually Setting Image Path for Carrierwave Uploader
body: <p>In my rails app, I let users upload images via CarrierWave (so I have an "Image" model).  I also let them embed Youtube videos (using a "Video" model).  Every time the user adds a Youtube video, I'd like to create an Image record using the Youtube thumbnail image.  However, when I try to create a new Image record by manually setting the path of the image, it's seen as "null" rather than the image url.  For example, if enter the following into my rails console:</p>
  
  <pre><code>Image.new(:image_path=&gt;"http://img.youtube.com/vi/O9k-MsfIkMY/default.jpg").save
  </code></pre>
  
  <p>I get the following log message:</p>
  
  <pre><code>INSERT INTO "images" ("caption", "created_at", "image_path", "position", "project_id", "saved", "step_id", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"  [["caption", nil], ["created_at", Fri, 05 Jul 2013 15:57:54 EDT -04:00], ["image_path", nil], ["position", nil], ["project_id", nil], ["saved", nil], ["step_id", nil], ["updated_at", Fri, 05 Jul 2013 15:57:54 EDT -04:00]]
  </code></pre>
  
  <p><strong>How can I manually set the image path?</strong></p>
  
  <p><strong>Image.rb:</strong></p>
  
  <pre><code>class Image &lt; ActiveRecord::Base
  
    attr_accessible :project_id, :step_id, :image_path, :caption, :position, :saved
  
    belongs_to :step
    belongs_to :project
  
    mount_uploader :image_path, ImagePathUploader
  
    before_create :default_name
  
    # validates :image_path, :presence =&gt; true
  
    def default_name
      self.image_path ||= File.basename(image_path.filename, '.*').titleize if image_path
    end
  
  end
  </code></pre>