Create csv from csv content

This commit is contained in:
Adam
2015-12-31 00:07:43 +01:00
parent d73b8ca8d8
commit ca91c3d16f
2 changed files with 23 additions and 3 deletions

View File

@@ -1,5 +1,13 @@
module ItemsHelper
def self.create_csv(data)
file = Tempfile.new([Rails.root.join('tmp/').to_s, ".csv"], "")
csv = CSV.new(file)
data.each do |row|
csv << row
end
end
file.rewind
file.close
file
end
end