Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #45 from SpringRoll/161-take-two
Browse files Browse the repository at this point in the history
fix slug bug
  • Loading branch information
chipbell4 authored Oct 30, 2018
2 parents d9a05b2 + 2c67551 commit c419f14
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/routes/games/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ router.patch('/:slug', function(req, res){
.then(game => {
return Game.findByIdAndUpdate(game._id, req.body);
})
.then(() =>{
// have to re-get game b/c archived status may have been changed
Game.getBySlug(req.params.slug).then(game => {
.then(game => {
// have to re-get because slug may have changed
Game.findById(game._id).then(game => {
if (game.isArchived){
res.redirect('/archive/' + req.params.slug);
res.redirect('/archive/' + game.slug);
}
else {
res.redirect('/games/' + req.params.slug);
res.redirect('/games/' + game.slug);
}
});
});
Expand Down

0 comments on commit c419f14

Please sign in to comment.