From a2b6409460d0a7996760d3cc010e6bafa0ad4a0e Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 11 Sep 2015 12:44:10 +0300 Subject: [PATCH] Refactor #2825 --- app/models/epp/domain.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index e38b5b150..236adb786 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -12,13 +12,8 @@ class Epp::Domain < Domain after_validation :validate_contacts def validate_contacts ok = true - if new_record? - ac = admin_domain_contacts.map(&:contact) - tc = tech_domain_contacts.map(&:contact) - else - ac = contacts - tc = [] - end + ac = admin_domain_contacts.includes(:contact).select { |x| !x.marked_for_destruction? }.map(&:contact) + tc = tech_domain_contacts.includes(:contact).select { |x| !x.marked_for_destruction? }.map(&:contact) # validate registrant here as well ([registrant] + ac + tc).each do |x| unless x.valid?