Created
February 13, 2013 00:08
-
-
Save muZk/4774845 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ROUTING | |
var albums = require("../app/controllers/album") | |
app.get("/admin/album/:album_id",albums.edit) | |
app.param('album_id', albums.album); | |
// CONTROLLER | |
exports.album = function(res,req,next,album_id){ | |
Album.findOne({ _id: album_id }).exec(function (err,album){ | |
if(err) return next(err) | |
if(!album) return next(new Error('Failed to load Album '+album_id)) | |
req.album = album | |
console.log(album) | |
next() | |
}) | |
} | |
exports.edit = function(res,req) { | |
var album = req.album; | |
console.log(res) | |
console.log(album) | |
res.render("album/edit",{ album: album }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment