Skip to content

Instantly share code, notes, and snippets.

@mde
Last active December 16, 2015 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mde/5368115 to your computer and use it in GitHub Desktop.
Save mde/5368115 to your computer and use it in GitHub Desktop.
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