Skip to content

Commit

Permalink
Remove reliance on noid for find (#6924)
Browse files Browse the repository at this point in the history
* Remove reliance on noid for find

Switches from using noids to using a fallback... look first by id,
and then by alternate_identifier instead.

I created a work in dassie with VALKYRIE_TRANSITION=true and then I was
unable to edit the work because I don’t have an alternative identifier.

* Rearrange code to allow fallback to alternative_id
  • Loading branch information
laritakr authored Oct 16, 2024
1 parent 13b6c9e commit 0f522be
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/hyrax/valkyrie_can_can_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ def self.for_class?(member_class)
#
# @raise Hyrax::ObjectNotFoundError
def self.find(_model_class, id)
return Hyrax.query_service.find_by(id: id) unless Hyrax.config.enable_noids?
self.find_by(id:) ||
Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: id)
rescue Valkyrie::Persistence::ObjectNotFoundError => err
raise Hyrax::ObjectNotFoundError, err.message
end

private

def self.find_by(id:)
Hyrax.query_service.find_by(id:)
rescue Valkyrie::Persistence::ObjectNotFoundError
end
end
end

0 comments on commit 0f522be

Please sign in to comment.