title: How to upload an image with other form inputs via ruby on rails?
body: <p>I was wondering how to implement an image upload using ruby on rails v3?
  What I got so far is the image is uploaded to my public/uploads directory but in the database the hashed value from the form is stored.</p>
  
  <p>EX of hashed value:</p>
  
  <pre><code>!ruby/object:ActionDispatch::Http::UploadedFile 
  content_type: image/jpeg
  headers: |
    Content-Disposition: form-data; name="farmer[picture]"; filename="picture.JPG"
    Content-Type: image/jpeg
  
  original_filename: picture.JPG
  tempfile: !ruby/object:File {}
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>def new
      @farmer = Farmer.new
    end
  
    def create
      @farmer = Farmer.new(params[:farmer])
      if @farmer.save
        uploaded_io = params[:farmer][:picture]
        File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'w') do |file|
          file.write(uploaded_io.read)
        end
        flash[:success] = "#{@farmer.firstName} #{@farmer.lastName} added"
        redirect_to @farmer
      else
        redirect_to new_path
      end
    end
  </code></pre>
  
  <p>Model:
  empty</p>
  
  <p>View:</p>
  
  <pre><code>&lt;%= form_for(@farmer, :html =&gt; { :multipart =&gt; true }) do |f| %&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :picture, "Picture" %&gt;
      &lt;%= f.file_field :picture %&gt;
    &lt;/div&gt;
    &lt;div class="actions"&gt;
      &lt;%= f.submit "Post"%&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>So what I would like help with is how to store uploads/image.JPG into the database not the hashed value?</p>