Don't create new legaldoc if it's already persistent

This commit is contained in:
Karl Erik Õunapuu 2020-07-07 15:23:23 +03:00
parent eb09447ee1
commit 58443f23aa
2 changed files with 4 additions and 14 deletions

View file

@ -28,18 +28,9 @@ class LegalDocument < ApplicationRecord
end
def val_body_length
if body.start_with? ENV['legal_documents_dir']
if File.exist? body
self.path = body
self.body = nil
return
end
end
errors.add(:body, :length) if body.nil? || body.size < MIN_BODY_SIZE
end
def save_to_filesystem
binary = Base64.decode64(body)
digest = Digest::SHA1.new.update(binary).to_s