diya
diya

Reputation: 7138

How to write into a temporary file from Rails

How to write into a temporary file (in the temp folder of a machine) from a Rails app, I am using Spreadsheet::Workbook.new and I want the contents to be written into a temp file

Upvotes: 0

Views: 1944

Answers (1)

KARASZI István
KARASZI István

Reputation: 31467

You can use the Ruby's Tempfile:

file = Tempfile.new('prefix')

or with a block:

Tempfile.new('prefix') do |file|
  # do the work with the file
end

Upvotes: 3

Related Questions