I’ve got an array (@bigtable), filled with strings, and I want to save them to file where every row from array will be separate line, here is my code for saving file:
def savefile
@bigtable = Rails.cache.read("pass")
doc = "wyniki.csv"
File.open(doc, "w", :type => 'text/html; charset=utf-8'){ |f| f << @bigtable}
send_file(doc, :disposition => 'attachment')
end
Any ideas?
What’s the actual question? Writing the array?
(If it’s actually big, and you’re having memory issues, write it line-by-line.)
If it’s a CSV file, why set the type to
"text/html"? Would"text/csv"be more appropriate?