diff --git a/app.rb b/app.rb index 889293c..9529dc4 100644 --- a/app.rb +++ b/app.rb @@ -185,6 +185,10 @@ end # end get '/candidates/:id/?' do + if @deleted_candidate = DeletedCandidate.get(params[:id]) + redirect "/candidates/#{@deleted_candidate.candidate_id}", 301 # HTTP 301 Moved Permanently + end + if @candidate = Candidate.get(params[:id]) @candidacies = repository(:default).adapter.select(" SELECT diff --git a/models.rb b/models.rb index e995032..50ed220 100644 --- a/models.rb +++ b/models.rb @@ -86,6 +86,13 @@ class Candidate end end +class DeletedCandidate + include DataMapper::Resource + + property :old_candidate_id, Integer, :key => true # ID of candidate that has been merged/deleted + property :candidate_id, Integer, :required => true # ID of candidate that has been kept +end + class Candidacy include DataMapper::Resource