Rails Import: "No Implicit conversion of string into array"

402 views Asked by At

I'm attempting to import values from a spreadsheet into a table. I am adding new records for each row to an array, and then importing that array. My Code is below:

def import(path)

  spreadsheet = Roo::Spreadsheet.open(path+"Data.xlsx")
  sales = spreadsheet.sheet('Accounts')

  sales = sales.parse(headers: true)
  accounts = []

  sales.each do |row|
    a = HM::NewBusiness.new
    a.dealer_id = row["Dlr #"]
    a.dealer_name = row["Dealer Name"]
    a.duns = row["Duns Name"]
    a.industry = row["Type"]
    a.volume_2016 = row["volume_2016"]
    a.volume_2017 = row["volume_2017"]
    a.volume_2018 = row["volume_2018"]
    a.volume_2019 = row["volume_2019"]

    accounts << a
  end
  pp accounts
  HM::NewBusiness.import(accounts)

end

However when I run import, I get:

TypeError: no implicit conversion of String into Array

I can't figure out where I'm going wrong. Any help would be appreciated.

1

There are 1 answers

0
neanderslob On BEST ANSWER

Figured it out. The problem was that I coincidentally named the method itself "import". In short a 1d10t error.