From 72b693a25655f7a801837e4df764a04d812a3b1f Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Fri, 19 Apr 2024 13:42:54 -0700 Subject: [PATCH] :bug: User couldn't edit file sets parent_doc is not a solr document, so calling ['has_model_ssim'] produced and error. --- app/helpers/hyku_helper.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/helpers/hyku_helper.rb b/app/helpers/hyku_helper.rb index dd76ef205..4bb2bd9d6 100644 --- a/app/helpers/hyku_helper.rb +++ b/app/helpers/hyku_helper.rb @@ -21,8 +21,16 @@ def admin_only_tenant_creation? end def parent_path(parent_doc) - model = parent_doc['has_model_ssim'].first - path = "hyrax_#{model.underscore}_path" + model = case parent_doc + when ActiveFedora::Base + parent_doc + when SolrDocument + parent_doc['has_model_ssim'].first.constantize + else + raise "Unknown parent_doc type: #{parent_doc.class}" + end + + path = "#{model.model_name.singular_route_key}_path" main_app.send(path, parent_doc.id) end end