title: save image in database in rails
body: <p>In ruby on rails project, I get a url from user and use below http request and then show the result to user. The code is show below:</p>
  
  <p>problem.rb:</p>
  
  <pre><code>class Problem &lt; ActiveRecord::Base
    def content_length
  
      uri = URI.parse("http://png-4.findicons.com/files/icons/1607/ruby_on_rails/256/ror_folder_256_v3.png")
  
      response = Net::HTTP.start(uri.host, uri.port) { |http| http.request_head(uri.path)}
      response["content-length"].to_i
    end
  end
  </code></pre>
  
  <p>I get the image of this url and show the size and the picture of url to user:</p>
  
  <p>show.html.erb:</p>
  
  <pre><code>&lt;p&gt;
    &lt;strong&gt;Image Size:&lt;/strong&gt;
    &lt;%= number_to_human_size(@problem.content_length) %&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
    &lt;strong&gt;Image:&lt;/strong&gt;
    &lt;%= image_tag(@problem.url) %&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>Now, I save the url to the database, but I want save the image of this url in database too. How can save the image into database?</p>
  
  <p>Problem model, have a paperclip method that is get the image from upload the image from below code:</p>
  
  <pre><code>&lt;div class="field"&gt;
    &lt;%= f.label :photo %&gt;&lt;br&gt;
    &lt;%= f.file_field :photo %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Can I save the image of URL to paperclip of problems? If yes, how can I do it?</p>