title: Upload excel data using a combination of two columns?
body: <p>I have an excel sheet which has the format shown below:
  <a href="https://i.stack.imgur.com/YXdla.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YXdla.png" alt="enter image description here"></a></p>
  
  <p>Members can have multiple entries in the corresponding <code>members</code> table. When uploading data from the excel template, I would like to <code>find_by</code> <code>pin</code> as well as <code>end_date</code> so that I update the specific record during upload.</p>
  
  <p>I am using <code>gem roo</code> to import excel data, and here is my <code>load_imported_members</code> method:</p>
  
  <pre><code>def load_imported_members
      spreadsheet = open_spreadsheet
      spreadsheet.default_sheet = 'Worksheet'
      header = spreadsheet.row(1)
      (2..spreadsheet.last_row).map do |i|
        row = Hash[[header, spreadsheet.row(i)].transpose]
        member = Member.find_by_pin(row["pin"]) || Member.new
        member.attributes = row.to_hash.slice("id", "name", "pin", "end_date", "email")
        member
      end
    end
  
  </code></pre>
  
  <p>I reckon that if I use both <code>pin</code> and <code>end_date</code> in the <code>find_by</code> method, I will update the specific record, since there could be two entries in the table, but one must have an <code>end_date</code>. How can I achieve this? Thanks</p>