I am running this query and on puts I am getting an error TypeError: no implicit conversion of String into Integer if I just try to get the ID from the array.
puts billing_ids then the output is [<Billing id: 66, date: "2019-11-31", created_at: "2019-04-22 22:28:23", updated_at: "2020-01-15 17:03:05">]
And if I do puts "#{billing_ids["id"]}" to get just the id then I get the error TypeError: no implicit conversion of String into Integer
Please help me figure out how can I get the 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
Output
[#<Billing id: 66, date: "2019-11-31", created_at: "2019-04-22 22:28:23", updated_at: "2020-01-15 17:03:05">]
puts billing_idsand post the output herebilling_ids.map(&:id)as yourbilling_idsarray has objects and not just ids