Last active
December 16, 2015 03:09
-
-
Save mde/5368115 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var Zoobies = function () { | |
this.respondsWith = ['json', 'js', 'xml]; | |
this.create = function (req, resp, params) { | |
var self = this | |
, zooby = geddy.model.Zooby.create(params); | |
if (!zooby.isValid()) { | |
params.errors = zooby.errors; | |
// Figure out how you want to respond with an error | |
// See `error` method for controllers | |
} | |
zooby.save(function(err, data) { | |
if (err) { | |
params.errors = err; | |
// Figure out how you want to respond with an error | |
// See `error` method for controllers | |
} else { | |
self.respond(null, {statusCode: 201}); | |
} | |
}); | |
}; | |
}; | |
exports.Zoobies = Zoobies; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment