title: Reading in file contents rails
body: <p>I have a form that is attempting to read in a JSON file for parsing/actions/etc. I'm having problems getting it to read in the controller.</p>
  
  <p>View:</p>
  
  <pre><code>&lt;%= form_tag({:controller =&gt; :admins, :action =&gt; :upload_json}, {:multipart =&gt; true, :method =&gt; :post}) do |f| %&gt;
  
      &lt;%= file_field_tag 'datafile' %&gt;
  
  &lt;%= submit_tag "Upload" %&gt;
  </code></pre>
  
  
  
  <p>Controller: </p>
  
  <pre><code>def upload_json
  
    file_data = params[:datafile]
  
    File.read(file_data) do |file|
  
       file.each do |line|
         ## does stuff here....
       end
    end
  
  end
  </code></pre>
  
  <p>A similar function works in my <code>seed.rb</code> file when I'm seeding data - just can't get it to read in an uploaded file.</p>
  
  <p>The error I'm getting is: <code>can't convert ActionDispatch::Http::UploadedFile into String</code>.</p>
  
  <p>Thanks in advance for the help!</p>