Skip to content

Commit

Permalink
redirects a work to its proper route (#1761)
Browse files Browse the repository at this point in the history
* redirects a work to its proper route

* limit before action to the show page

* redirect with moved permanently
  • Loading branch information
revgum authored and wickr committed Nov 8, 2018
1 parent d36c1ca commit 5f246da
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ module WorksControllerBehavior
extend ActiveSupport::Concern
include Hyrax::WorksControllerBehavior
included do
before_action :redirect_mismatched_work, only: [:show]
before_action :migrate_work_in_place, only: [:edit, :show]

def redirect_mismatched_work
curation_concern = ActiveFedora::Base.find(params[:id])
if curation_concern.class != _curation_concern_type
redirect_to(main_app.polymorphic_path(curation_concern), status: :moved_permanently) and return
end
end

def migrate_work_in_place
work = ActiveFedora::Base.find(params[:id])
unless Migrator.has_migrated?(work: work)
Expand Down

0 comments on commit 5f246da

Please sign in to comment.