Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure tmp exists at app root, and use it #575

Merged
merged 2 commits into from
May 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions app/models/journal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ def create_spreadsheet
rows = journal_rows
return false if rows.empty?

# write journal spreadsheet to tmp directory
# temp_file = Tempfile.new("journalspreadsheet")
temp_file = File.new("#{Dir.tmpdir}/journal.spreadsheet.#{Time.zone.now.strftime('%Y%m%dT%H%M%S')}.xls", "w")
output_file = JournalSpreadsheet.write_journal_entry(rows, output_file: temp_file.path)
# add/import journal spreadsheet
status = add_spreadsheet(output_file)
Expand All @@ -25,6 +22,16 @@ def create_spreadsheet
status
end

private

def temp_file
@temp_file ||= File.new(spreadsheet_filename, "w")
end

def spreadsheet_filename
Rails.root.join("tmp/journal.spreadsheet.#{Time.current.strftime('%Y%m%dT%H%M%S')}.xls")
end

end

include DownloadableFile
Expand Down
Empty file added tmp/.keep
Empty file.