Rails 导入:"No Implicit conversion of string into array"

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

我正在尝试将电子表格中的值导入 table。我将每一行的新记录添加到一个数组,然后导入该数组。我的代码如下:

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

但是当我 运行 import 时,我得到:

TypeError: no implicit conversion of String into Array

我不知道哪里出了问题。任何帮助将不胜感激。

想通了。问题是我巧合地将方法本身命名为 "import"。简而言之,1d10t 错误。