Skip to content

Commit

Permalink
don't break on UrlHelper load if models aren't ActiveModel conformant
Browse files Browse the repository at this point in the history
not all possible `registered_curation_concern_types` (or `FileSet`s or
`Collection`s) have a model name. likewise, `registered_curation_concern_types`
contains strings, which might not be constantizable by mistake. if the rest of
the application works under these conditions, just skip defining track paths.

note that this module is eagerly loaded and run (only in production, for usual
app configurations!) even if it's not included anywhere in the downstream
application. this is a bad time to break someone's app on startup over code they
didn't load themselves.
  • Loading branch information
tamsin johnson committed Apr 2, 2021
1 parent 96156de commit 8475f46
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/helpers/hyrax/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module UrlHelper
# generated models get registered as curation concerns and need a
# track_model_path to render Blacklight-related views
(['FileSet', 'Collection'] + Hyrax.config.registered_curation_concern_types).each do |concern|
define_method("track_#{concern.constantize.model_name.singular_route_key}_path") { |*args| main_app.track_solr_document_path(*args) }
model_name = concern.safe_constantize.try(:model_name)
next unless model_name
define_method("track_#{model_name.singular_route_key}_path") { |*args| main_app.track_solr_document_path(*args) }
end
end
end

0 comments on commit 8475f46

Please sign in to comment.