From f01e4ed6ef75655a1e8d7066b51abfa1b96f3e37 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 28 Sep 2021 16:05:49 +0200 Subject: [PATCH] models: document upstream PR about file size validation --- app/models/concerns/file_validation_concern.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/concerns/file_validation_concern.rb b/app/models/concerns/file_validation_concern.rb index a9284212f..a3237d43f 100644 --- a/app/models/concerns/file_validation_concern.rb +++ b/app/models/concerns/file_validation_concern.rb @@ -1,6 +1,10 @@ module FileValidationConcern extend ActiveSupport::Concern class_methods do + # This method works around missing `%{min_size}` and `%{max_size}` variables in active_record_validation + # default error message. + # + # Hopefully this will be fixed upstream in https://github.com/igorkasyanchuk/active_storage_validations/pull/134 def file_size_validation(file_max_size = 200.megabytes) { less_than: file_max_size, message: I18n.t('errors.messages.file_size_out_of_range', file_size_limit: ActiveSupport::NumberHelper.number_to_human_size(file_max_size)) } end