Преглед на файлове

Create redirects for merged/deleted candidates so old URLs still work

tags/last-sinatra-version
Adrian Short преди 10 години
родител
ревизия
7cc3641b0e
променени са 2 файла, в които са добавени 11 реда и са изтрити 0 реда
  1. +4
    -0
      app.rb
  2. +7
    -0
      models.rb

+ 4
- 0
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


+ 7
- 0
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



Зареждане…
Отказ
Запис