我正在运行此查询,并且在put上出现错误TypeError: no implicit conversion of String into Integer if I just try to get the ID from the array。
puts billing_ids然后输出是[<Billing id: 66, date: "2019-11-31", created_at: "2019-04-22 22:28:23", updated_at: "2020-01-15 17:03:05">]
如果我确实将 "#{billing_ids["id"]}"用于获取 id,那么我会收到错误TypeError: no implicit conversion of String into Integer
请帮我弄清楚如何获得ID。
Office.all.each do |office|
billing_ids=[] #initialize array
office.issues.where("issues.amount > 0").each do |issue|
billing_ids << issue.billings.where("billings.date < ?", Message.last.date).order(:date).last.id #add id to array
end
puts "#{billing_ids["id"]}"
end
输出
[#<Billing id: 66, date: "2019-11-31", created_at: "2019-04-22 22:28:23", updated_at: "2020-01-15 17:03:05">]