From c0357c7717d8d6886a6569d987714f7ed74072f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Thu, 8 Jan 2015 17:47:54 +0200 Subject: [PATCH] Contact associations loaded eagerly where needed --- app/helpers/epp/contacts_helper.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index 702efa5ee..20982b336 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -39,9 +39,11 @@ module Epp::ContactsHelper def info_contact handle_errors(@contact) and return unless @contact handle_errors(@contact) and return unless rights? - @disclosure = ContactDisclosure.default_values.merge(@contact.disclosure.try(:as_hash) || {}) + @disclosure = ContactDisclosure.default_values.merge(@contact.disclosure.try(:as_hash) || {}) @disclosure_policy = @contact.disclosure.try(:attributes_with_flag) @owner = owner?(false) + # need to reload contact eagerly + @contact = find_contact('with eager load') if @owner # for clarity, could just be true render 'epp/contacts/info' end @@ -109,8 +111,12 @@ module Epp::ContactsHelper ## SHARED - def find_contact - contact = Contact.find_by(code: @ph[:id]) + def find_contact(eager_load=nil) + if eager_load + contact = Contact.includes(address: :country).find_by(code: @ph[:id]) + else + contact = Contact.find_by(code: @ph[:id]) + end unless contact epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist'),