title: Rails paperclip image URL uploading not working
body: <p>I am trying to create some image url upload. My file upload field works, but when I submit a URL it submit and renders my indeks page and no image gets uploaded. </p>
  
  <p>Here is my model: </p>
  
  <pre><code>class Konkurrancer &lt; ActiveRecord::Base
  
      has_attached_file :photo,
                        :url  =&gt; "/public/images/billeder/photo/:id/:basename.:extension",
                        :path =&gt; ":rails_root/public/images/billeder/photo/:id/:basename.:extension"
  
      has_attached_file :photo2,
                        :url  =&gt; "/public/images/billeder/photo2/:id/:basename.:extension",
                        :path =&gt; ":rails_root/public/images/billeder/photo2/:id/:basename.:extension"
  
        attr_accessor :photo_url, :photo_url2
  
        def photo_url=(url) 
          return if url.blank?
          self.photo = RemoteUpload.new(url)
        end
  
        def photo_url2=(url) 
          return if url.blank?
          self.photo2 = RemoteUpload.new(url)
        end
  end
  </code></pre>
  
  <p>My controller: </p>
  
  <pre><code>    def new
          @konkurrancer = Konkurrancer.new
          if !params[:konkurrancer].nil? &amp;&amp; !params[:konkurrancer][:photo_url].blank?
          # user entered a photo url, use the url
          @konkurrancer.photo_remote_url = params[:konkurrancer][:photo_remote_url]
          elsif !params[:konkurrancer].nil? &amp;&amp; !params[:konkurrancer][:photo]
           # use file upload  
          @konkurrancer.photo = params[:konkurrancer][:photo]
      end
  
      if !params[:konkurrancer].nil? &amp;&amp; !params[:konkurrancer][:photo_url_2].blank?
        # user entered a photo url, use the url
        @konkurrancer.photo_remote_url = params[:konkurrancer][:photo_remote_url_2]
      elsif !params[:konkurrancer].nil? &amp;&amp; !params[:konkurrancer][:photo]
        # use file upload
        @konkurrancer.photo2 = params[:konkurrancer][:photo2]
      end
  
          respond_to do |format|
            format.html # new.html.erb
            format.xml  { render :xml =&gt; @konkurrancer }
          end
        end
  
    # POST /konkurrancers
        # POST /konkurrancers.xml
        def create
          @konkurrancer = Konkurrancer.new(params[:konkurrancer])
  
          respond_to do |format|
            if @konkurrancer.save
              format.html { redirect_to(:admin_konkurrancers, :notice =&gt; 'Konkurrancer was successfully created.') }
              format.xml  { render :xml =&gt; :admin_konkurrancers, :status =&gt; :created, :location =&gt; @konkurrancer }
            else
              format.html { render :action =&gt; "new" }
              format.xml  { render :xml =&gt; @konkurrancer.errors, :status =&gt; :unprocessable_entity }
            end
          end
        end
  </code></pre>
  
  <p>My remote_upload.rb: </p>
  
  <pre><code>require 'open-uri'
  
  # Make it always write to tempfiles, never StringIO
  OpenURI::Buffer.module_eval {
    remove_const :StringMax
    const_set :StringMax, 0
  }
  
  class RemoteUpload 
  
    attr_reader :original_filename, :attachment_data
  
    def initialize(url) 
      # read remote data
      @attachment_data    = open(url)
  
      # determine filename
      path = self.attachment_data.base_uri.path
  
      # we need this attribute for compatibility to paperclip etc.
      @original_filename = File.basename(path).downcase
    end
  
    # redirect method calls to uploaded file (like size etc.)
    def method_missing(symbol, *args)
      if self.attachment_data.respond_to? symbol
        self.attachment_data.send symbol, *args
      else
        super
      end
    end
  
  end
  </code></pre>
  
  <p>My view: </p>
  
  <pre><code>&lt;%= simple_form_for [:admin, @konkurrancer], :html =&gt; { :multipart =&gt; true } do |f| %&gt;
      &lt;%= f.input :name, :label =&gt; 'Titel', :style =&gt; 'width:500;' %&gt;
      &lt;%= f.label :upload_125x125 %&gt;
      &lt;%= f.file_field :photo, :label =&gt; '125x125', :style =&gt; 'width:250;' %&gt;
      &lt;%= f.input :photo_url, :label =&gt; 'URL 125x125', :style =&gt; 'width:250;' %&gt;
      &lt;%= f.label :upload_460x60 %&gt;
      &lt;%= f.file_field :photo2, :label =&gt; '460x58', :style =&gt; 'width:250;' %&gt;
      &lt;%= f.input :photo_url2, :label =&gt; 'URL 460x58', :style =&gt; 'width:250;' %&gt;
      &lt;%= f.button :submit, :value =&gt; 'Create konkurrence' %&gt;
  &lt;% end %&gt;
  </code></pre>