Class: Hyrax::RedirectsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/hyrax/redirects_controller.rb

Overview

See documentation/redirects.md for the redirects feature.

Wired up as a catch-all route in the host application's config/routes.rb (see the install generator). Serves any path not claimed by an earlier route when the feature is active.

Instance Method Summary collapse

Instance Method Details

#showObject

Raises:

  • (ActionController::RoutingError)


10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/hyrax/redirects_controller.rb', line 10

def show
  row = Hyrax::RedirectsLookup.find_row(params[:alias_path])
  raise ActionController::RoutingError, 'Not Found' if row.blank?

  if row.is_display_url?
    dispatch_in_place(row)
  else
    redirect_to with_locale(row.to_path), status: :moved_permanently
  end
end