Validate body is present

This commit is contained in:
Mathieu Magnin 2017-11-07 20:40:00 +01:00
parent 6c39aba978
commit 4d12aa222c
3 changed files with 12 additions and 2 deletions

View file

@ -6,6 +6,7 @@ class Commentaire < ActiveRecord::Base
mount_uploader :file, CommentaireFileUploader
validates :file, file_size: { maximum: 20.megabytes, message: "La taille du fichier doit être inférieure à 20 Mo" }
validate :is_virus_free?
validates_presence_of :body, message: "Votre message ne peut être vide"
default_scope { order(created_at: :asc) }
scope :updated_since?, -> (date) { where('commentaires.updated_at > ?', date) }