From 9a76ee8f8a2fffc07fdd4655445d292bf5352024 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Sun, 3 May 2015 19:26:54 +0200 Subject: [PATCH] FIX: error message used wrong filesize --- lib/validators/upload_validator.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/validators/upload_validator.rb b/lib/validators/upload_validator.rb index e386931d717..985fe928d9a 100644 --- a/lib/validators/upload_validator.rb +++ b/lib/validators/upload_validator.rb @@ -78,9 +78,10 @@ class Validators::UploadValidator < ActiveModel::Validator end def maximum_file_size(upload, type) - max_size_kb = SiteSetting.send("max_#{type}_size_kb").kilobytes + max_size_kb = SiteSetting.send("max_#{type}_size_kb") + max_size_bytes = max_size_kb.kilobytes - if upload.filesize > max_size_kb + if upload.filesize > max_size_bytes message = I18n.t("upload.#{type}s.too_large", max_size_kb: max_size_kb) upload.errors.add(:filesize, message) end