mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 03:58:27 +02:00
Structure legal documents directory #2667
This commit is contained in:
parent
72bb02825d
commit
cce185cf9d
1 changed files with 4 additions and 1 deletions
|
@ -15,7 +15,10 @@ class LegalDocument < ActiveRecord::Base
|
|||
loop do
|
||||
rand = SecureRandom.random_number.to_s.last(4)
|
||||
next if rand.to_i == 0 || rand.length < 4
|
||||
self.path = "#{ENV['legal_documents_dir']}/#{Time.zone.now.to_formatted_s(:number)}_#{rand}.#{document_type}"
|
||||
|
||||
dir = "#{ENV['legal_documents_dir']}/#{Time.zone.now.strftime('%Y/%m/%d')}"
|
||||
FileUtils.mkdir_p(dir)
|
||||
self.path = "#{dir}/#{Time.zone.now.to_formatted_s(:number)}_#{rand}.#{document_type}"
|
||||
break unless File.file?(path)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue