Module: Hyrax::PermalinkPath

Defined in:
app/services/hyrax/permalink_path.rb

Overview

Returns the canonical, UUID-based path for a Hyrax resource (e.g. '/concern/generic_works/' or '/collections/').

Collections are routed by the Hyrax engine; works are routed by the host app's curation-concern resources, so the picker consults resource.collection? to choose the right route helper.

Class Method Summary collapse

Class Method Details

.call(resource) ⇒ String

Returns the canonical path, e.g. '/concern/generic_works/'.

Parameters:

  • resource (#collection?)

    a Hyrax::Resource (work or collection)

Returns:

  • (String)

    the canonical path, e.g. '/concern/generic_works/'



15
16
17
18
# File 'app/services/hyrax/permalink_path.rb', line 15

def call(resource)
  helpers = collection_resource?(resource) ? Hyrax::Engine.routes.url_helpers : Rails.application.routes.url_helpers
  helpers.polymorphic_path(resource)
end