title: Ruby - Inserting entries from CSV into database
body: <p>I have an uploaded CSV file, which I parse like so:</p>
  
  <pre><code>CSV.foreach(@my_file.file.path) do |row|
      puts row[1]
  end
  </code></pre>
  
  <p>The incoming CSV file has at least the following columns: "id", "name", "number", "phone", and "food".</p>
  
  <p>I would like to do something like:</p>
  
  <pre><code>CSV.foreach(@my_file.file.path) do |row|
       //find the columns in "row" associated with "id", "name", "number"
       //even though I don't know definitively which column they will be in
       //for example, "name" may be the 2nd or 3rd or 4th column (etc)
  
       //insert into my_table values(id, name, number)
  
  end
  </code></pre>
  
  <p>Note that the CSV file will always have column names as the first row, however from file to file, the ordering of those columns may differ.</p>