Merge pull request #40 from sgmap/destroy_emails_with_procedure

Destroy emails with procedure
This commit is contained in:
LeSim 2017-03-13 13:59:32 +01:00 committed by GitHub
commit 8f5f86b2f3

View file

@ -39,7 +39,7 @@ class Procedure < ActiveRecord::Base
MAIL_TEMPLATE_TYPES = %w(InitiatedMail ReceivedMail ClosedMail RefusedMail WithoutContinuationMail)
MAIL_TEMPLATE_TYPES.each do |name|
has_one "#{name.underscore}".to_sym, class_name: "Mails::#{name}"
has_one "#{name.underscore}".to_sym, class_name: "Mails::#{name}", dependent: :destroy
define_method("#{name.underscore}_with_override") do
self.send("#{name.underscore}_without_override") || Object.const_get("Mails::#{name}").default
end