mirror of
https://github.com/internetee/registry.git
synced 2025-05-29 09:00:02 +02:00
Contact associations loaded eagerly where needed
This commit is contained in:
parent
2a1786bb51
commit
c0357c7717
1 changed files with 9 additions and 3 deletions
|
@ -39,9 +39,11 @@ module Epp::ContactsHelper
|
||||||
def info_contact
|
def info_contact
|
||||||
handle_errors(@contact) and return unless @contact
|
handle_errors(@contact) and return unless @contact
|
||||||
handle_errors(@contact) and return unless rights?
|
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)
|
@disclosure_policy = @contact.disclosure.try(:attributes_with_flag)
|
||||||
@owner = owner?(false)
|
@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'
|
render 'epp/contacts/info'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -109,8 +111,12 @@ module Epp::ContactsHelper
|
||||||
|
|
||||||
## SHARED
|
## SHARED
|
||||||
|
|
||||||
def find_contact
|
def find_contact(eager_load=nil)
|
||||||
contact = Contact.find_by(code: @ph[:id])
|
if eager_load
|
||||||
|
contact = Contact.includes(address: :country).find_by(code: @ph[:id])
|
||||||
|
else
|
||||||
|
contact = Contact.find_by(code: @ph[:id])
|
||||||
|
end
|
||||||
unless contact
|
unless contact
|
||||||
epp_errors << { code: '2303',
|
epp_errors << { code: '2303',
|
||||||
msg: t('errors.messages.epp_obj_does_not_exist'),
|
msg: t('errors.messages.epp_obj_does_not_exist'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue