diff --git a/app/models/dunlop/target_file_model.rb b/app/models/dunlop/target_file_model.rb index 696140c..7bdf575 100644 --- a/app/models/dunlop/target_file_model.rb +++ b/app/models/dunlop/target_file_model.rb @@ -7,7 +7,7 @@ module Dunlop::TargetFileModel if attachment.persisted? {} else - {'Content-Disposition' => %|attachment; filename="#{attachment.target_basename}"|} # can be resource based and only available on initialization. Therefore persisted? + {'Content-Disposition' => %|attachment; filename="#{File.basename(attachment.local_target_filename)}"|} # can be resource based and only available on initialization. Therefore persisted? end end @@ -64,8 +64,10 @@ module Dunlop::TargetFileModel end def local_target_filename - result = File.join(Rails.application.config.working_path, target_basename) - gzip_file? ? result + ".gz" : result + @local_target_filename ||= begin + result = File.join(Rails.application.config.working_path, target_basename) + gzip_file? ? result + ".gz" : result + end end # Target file basename used on creation to deliver the desired file_name. @@ -85,7 +87,7 @@ module Dunlop::TargetFileModel # hook to implement post generation actions like sending by email and/or to other systems by means of web call and/or to create a transfer instance end - # Implement in Subclass. Example: + # Implement #data or this method in Subclass. Example: # CsvBuilder::BladiBla.new(resource).data def generate_file working_file.puts builder.data