From c92b249340fbdb2966632d3a50362dec43e44504 Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Thu, 22 Jul 2021 14:30:48 +0200 Subject: [PATCH] fixup! modify models --- app/models/commentaire.rb | 4 ++-- app/models/instructeur.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb index 895bc2f3f..f68b462a5 100644 --- a/app/models/commentaire.rb +++ b/app/models/commentaire.rb @@ -18,7 +18,7 @@ class Commentaire < ApplicationRecord belongs_to :instructeur, optional: true belongs_to :expert, optional: true - validate :messagerie_available?, on: :create + validate :messagerie_available?, on: :create, unless: -> { dossier.brouillon? } has_one_attached :piece_jointe @@ -95,7 +95,7 @@ class Commentaire < ApplicationRecord end def notify_user - DossierMailer.notify_new_answer(dossier).deliver_later + DossierMailer.notify_new_answer(dossier, body).deliver_later end def messagerie_available? diff --git a/app/models/instructeur.rb b/app/models/instructeur.rb index d3e2fc21b..588502504 100644 --- a/app/models/instructeur.rb +++ b/app/models/instructeur.rb @@ -26,6 +26,7 @@ class Instructeur < ApplicationRecord has_many :previously_followed_dossiers, -> { distinct }, through: :previous_follows, source: :dossier has_many :trusted_device_tokens, dependent: :destroy has_many :archives + has_many :bulk_messages, dependent: :destroy has_one :user, dependent: :nullify