I am using csv to export data. I am dynamically populating the fields and in order to do so i have added loop in to csv:
csv_data = CSV.generate do |csv|
csv << [
@userHeaders.each do |user|
"#{user.name}"
end
]
end
but this returns some thing like this: [#<User >, #<User >, #<User >, #<User >]
but when i tried to inspect the value after assigning it to a variable, it displays all the names that have been passed.
name = "#{user.name}"
puts name.inspect # (this diaplays all the names)
is there any format to display the data while looping inside csv?
please guide with answer
thanks
Try just using the
map(akacollect) method of your array: