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

Commit c419f14

Browse files
authored
Merge pull request #45 from SpringRoll/161-take-two
fix slug bug
2 parents d9a05b2 + 2c67551 commit c419f14

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/routes/games/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ router.patch('/:slug', function(req, res){
7979
.then(game => {
8080
return Game.findByIdAndUpdate(game._id, req.body);
8181
})
82-
.then(() =>{
83-
// have to re-get game b/c archived status may have been changed
84-
Game.getBySlug(req.params.slug).then(game => {
82+
.then(game => {
83+
// have to re-get because slug may have changed
84+
Game.findById(game._id).then(game => {
8585
if (game.isArchived){
86-
res.redirect('/archive/' + req.params.slug);
86+
res.redirect('/archive/' + game.slug);
8787
}
8888
else {
89-
res.redirect('/games/' + req.params.slug);
89+
res.redirect('/games/' + game.slug);
9090
}
9191
});
9292
});

0 commit comments

Comments
 (0)