mirror of
https://github.com/internetee/registry.git
synced 2025-07-26 04:28: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
|
loop do
|
||||||
rand = SecureRandom.random_number.to_s.last(4)
|
rand = SecureRandom.random_number.to_s.last(4)
|
||||||
next if rand.to_i == 0 || rand.length < 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)
|
break unless File.file?(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue