I need to use the tmp
folder on Heroku (Cedar) for writing some temporarily data, I am trying to do that this way:
open(\"#{Rails.root}/tmp/#{re
Is /tmp
included in your git repo? Removed in your .slugignore
? The directory may just not exist out on Heroku.
Try tossing in a quick mkdir before the write:
Dir.mkdir(File.join(Rails.root, 'tmp'))
Or even in an initializer or something...
Here's an elegant way
f = File.new("tmp/filename.txt", 'w')
f << "hi there"
f.close
Dir.entries(Dir.pwd.to_s + ("/tmp")) # See your newly created file in /tmp
Don't forget that whenever your app restarts (for any reason, including those outside your control), your files will be deleted, as they are only stored ephemerally.
Try it with heroku restart
, you will see the new file you created is no longer there