lib/active_fedora/aggregation/association.rb in activefedora-aggregation-0.4.1 vs lib/active_fedora/aggregation/association.rb in activefedora-aggregation-0.4.2

- old
+ new

@@ -54,10 +54,16 @@ return list if remainder.empty? index = remainder.find_index { |n| n.fetch('id') == first_id } first = remainder.delete_at(index) next_id = first['next_ssim'].try(:first) - create_linked_list(next_id, remainder, list + [first.fetch('proxyFor_ssim').first]) + proxy_for = first.fetch('proxyFor_ssim', []).first + if proxy_for + create_linked_list(next_id, remainder, list + [proxy_for]) + else + ActiveFedora::Base.logger.error("Found a proxy (id: #{first['id']}) that has no proxyFor_ssim") if ActiveFedora::Base.logger + create_linked_list(next_id, remainder, list) + end end def default_options { through: default_proxy_class, foreign_key: :target, has_member_relation: reflection.predicate, inserted_content_relation: content_relation } end