Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 14 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Showing with 10 additions and 3 deletions.
  1. +1 −1 package.json
  2. +2 −1 server/collection.js
  3. +7 −1 servers/Route.bones.js
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "bones",
"description": "Framework for using backbone.js on the client and server.",
- "version": "2.3.0",
+ "version": "2.4.0",
"author": {
"name": "Development Seed",
View
3 server/collection.js
@@ -10,7 +10,8 @@ Backbone.Collection.toString = function() {
Backbone.Collection.register = function(app) {
// Add the collection if it's not a server-only collection.
this.files.forEach(function(filename) {
- if (!(/\.server\.bones$/).test(filename) && app.assets) {
+ if (!(/\.server\.bones(\.js|)$/).test(filename) && app.assets &&
+ app.assets.models.indexOf(filename) < 0) {
app.assets.models.push(filename);
}
});
View
8 servers/Route.bones.js
@@ -110,6 +110,9 @@ server.prototype.loadCollection = function(req, res, next) {
server.prototype.loadModel = function(req, res, next) {
var name = req.params.model;
if (name in this.models) {
+ // `id` in param wins over `id` in request body.
+ if (req.body && 'id' in req.body && req.params.id)
+ req.body.id = req.params.id;
// Pass any querystring paramaters to the model.
req.model = new this.models[name]({ id: req.params.id }, req.query);
}
@@ -144,9 +147,12 @@ server.prototype.saveModel = function(req, res, next) {
server.prototype.delModel = function(req, res, next) {
if (!req.model) return next();
+ if (req.body && !req.model.set(req.body, {
+ error: function(model, err) { next(err); }
+ })) return;
req.model.destroy({
success: function(model, resp) {
- res.send({}, headers);
+ res.send(resp, headers);
},
error: function(model, err) {
var error = err instanceof Object ? err.message : err;

No commit comments for this range

Something went wrong with that request. Please try again.