mirror of
https://github.com/internetee/registry.git
synced 2025-07-02 17:23:34 +02:00
Ensure generated numbers are always numbers
This commit is contained in:
parent
12e32af524
commit
f838a6506c
5 changed files with 14 additions and 2 deletions
|
@ -5,6 +5,7 @@ class SaveLegalDocsToDisk < ActiveRecord::Migration
|
|||
path = nil
|
||||
loop do
|
||||
rand = SecureRandom.random_number.to_s.last(4)
|
||||
next if rand.to_i == 0 || rand.length < 4
|
||||
path = "#{ENV['legal_documents_dir']}/#{Time.zone.now.to_formatted_s(:number)}_#{rand}.#{x.document_type}"
|
||||
break unless File.file?(path)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue