Merge pull request #255 from tetebueno/patch-1

Creating exports directory if it doesn't exist
This commit is contained in:
Evgenii Burmakin 2024-09-16 22:30:10 +03:00 committed by GitHub
commit adf32353ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -72,8 +72,9 @@ class Exports::Create
end
def create_export_file(data)
file_path = Rails.root.join('public', 'exports', "#{export.name}.#{file_format}")
dir_path = Rails.root.join('public', 'exports')
Dir.mkdir(dir_path) unless Dir.exist?(dir_path)
file_path = dir_path.join("#{export.name}.#{file_format}")
File.open(file_path, 'w') { |file| file.write(data) }
end
end