diff --git a/app/controllers/registrant/domains_controller.rb b/app/controllers/registrant/domains_controller.rb index 7a19eadd2..50aac75f3 100644 --- a/app/controllers/registrant/domains_controller.rb +++ b/app/controllers/registrant/domains_controller.rb @@ -2,6 +2,11 @@ class Registrant::DomainsController < RegistrantController def index authorize! :view, :registrant_domains ident_cc, ident = @current_user.registrant_ident.split '-' - @domains = BusinessRegistryCache.fetch_associated_domains ident, ident_cc + begin + @domains = BusinessRegistryCache.fetch_associated_domains ident, ident_cc + rescue Soap::Arireg::NotAvailableError => error + flash[:notice] = I18n.t(error.message[:message]) + @domains = [] + end end end diff --git a/app/models/business_registry_cache.rb b/app/models/business_registry_cache.rb index b590853f5..5d6010674 100644 --- a/app/models/business_registry_cache.rb +++ b/app/models/business_registry_cache.rb @@ -48,7 +48,7 @@ class BusinessRegistryCache < ActiveRecord::Base cache = BusinessRegistryCache.find_by(ident: ident_code, ident_country_code: ident_cc) # fetch new data if cache is expired return cache if cache.present? && cache.retrieved_on > (Time.zone.now - Setting.days_to_keep_business_registry_cache.days) - cache = nil # expired data is forbidden + cache = [] # expired data is forbidden data = business_registry.associated_businesses(ident_code, ident_cc) unless data.nil? cache = BusinessRegistryCache.new(data) diff --git a/app/views/registrant/domains/index.haml b/app/views/registrant/domains/index.haml index d9f1db882..f8c03b8af 100644 --- a/app/views/registrant/domains/index.haml +++ b/app/views/registrant/domains/index.haml @@ -16,7 +16,7 @@ %th{class: 'col-xs-2'} = t(:registrar) %tbody - - @domains.each do |x| + - @domains.try(:each) do |x| %tr %td= x %td= x.registrant