ADD FILE_MAX_SIZE constant to set allow file size limit

This commit is contained in:
Ismael MOUSSA S 2021-09-14 18:03:40 +02:00 committed by Pierre de La Morinerie
parent bda3270b58
commit bdbb4deb87
7 changed files with 23 additions and 16 deletions

View file

@ -24,9 +24,10 @@ class Commentaire < ApplicationRecord
validates :body, presence: { message: "ne peut être vide" }
FILE_MAX_SIZE = 20.megabytes
validates :piece_jointe,
content_type: AUTHORIZED_CONTENT_TYPES,
size: { less_than: 20.megabytes }
size: { less_than: FILE_MAX_SIZE }
default_scope { order(created_at: :asc) }
scope :updated_since?, -> (date) { where('commentaires.updated_at > ?', date) }