From e2c45bad46ef25094902d0bb374582cd77a1f771 Mon Sep 17 00:00:00 2001 From: tetebueno <9064236+tetebueno@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:10:19 -0300 Subject: [PATCH] Creating exports directory if it doesn't exist. On my first export I found out that it failed because the exports directory didn't exist. Creating the directory and retrying the export fixed it. --- app/services/exports/create.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/exports/create.rb b/app/services/exports/create.rb index c7c01718..b4e9d402 100644 --- a/app/services/exports/create.rb +++ b/app/services/exports/create.rb @@ -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