{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/sails/issues/1797","labels_url":"https://api.github.com/repos/balderdashy/sails/issues/1797/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/sails/issues/1797/comments","events_url":"https://api.github.com/repos/balderdashy/sails/issues/1797/events","html_url":"https://github.com/balderdashy/sails/issues/1797","id":34900220,"number":1797,"title":"Model Association method: remove, does not work.","user":{"login":"timestep","id":3488288,"avatar_url":"https://avatars.githubusercontent.com/u/3488288?v=3","gravatar_id":"","url":"https://api.github.com/users/timestep","html_url":"https://github.com/timestep","followers_url":"https://api.github.com/users/timestep/followers","following_url":"https://api.github.com/users/timestep/following{/other_user}","gists_url":"https://api.github.com/users/timestep/gists{/gist_id}","starred_url":"https://api.github.com/users/timestep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timestep/subscriptions","organizations_url":"https://api.github.com/users/timestep/orgs","repos_url":"https://api.github.com/users/timestep/repos","events_url":"https://api.github.com/users/timestep/events{/privacy}","received_events_url":"https://api.github.com/users/timestep/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/balderdashy/sails/labels/generators","name":"generators","color":"666666"}],"state":"closed","locked":false,"assignee":{"login":"sgress454","id":553428,"avatar_url":"https://avatars.githubusercontent.com/u/553428?v=3","gravatar_id":"","url":"https://api.github.com/users/sgress454","html_url":"https://github.com/sgress454","followers_url":"https://api.github.com/users/sgress454/followers","following_url":"https://api.github.com/users/sgress454/following{/other_user}","gists_url":"https://api.github.com/users/sgress454/gists{/gist_id}","starred_url":"https://api.github.com/users/sgress454/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgress454/subscriptions","organizations_url":"https://api.github.com/users/sgress454/orgs","repos_url":"https://api.github.com/users/sgress454/repos","events_url":"https://api.github.com/users/sgress454/events{/privacy}","received_events_url":"https://api.github.com/users/sgress454/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2014-06-03T20:18:42Z","updated_at":"2015-04-28T18:26:29Z","closed_at":"2015-04-28T18:26:29Z","body":"sails v0.10.0rc-7\r\n\r\n```\r\n  'removeUser': function(req,res,next){\r\n    var listID = req.param('id');\r\n    var userID = req.param('userID');\r\n    List.findOne({id:listID}).populate('users').exec(function (err,l){\r\n      if(err){ return console.log(err); }\r\n        if(!l){ return res.json('What'); }\r\n          else {\r\n            debugger;\r\n            l.users.remove(userID);\r\n            debugger;\r\n            l.save(function (err){\r\n              debugger;\r\n              if(err){ return console.log(err); }\r\n                List.publishUpdate(l.id,l);\r\n                return res.json({id:userID})\r\n            })\r\n          }\r\n    })\r\n  },\r\n```\r\n\r\nI'm calling l.users.remove(userID) and when I call save, l.users.length remains unchanged.\r\n\r\nI verify that the user I am attempting to remove from the list does in fact exist and is associated with the list.\r\n\r\nUser Model:\r\n```\r\n/**\r\n * User.js\r\n *\r\n * @description :: TODO: You might write a short summary of how this model works and what it represents here.\r\n * @docs\t\t:: http://sailsjs.org/#!documentation/models\r\n */\r\n\r\nmodule.exports = {\r\n\r\n\tattributes: {\r\n\r\n\t\tfirstname:{\r\n\t\t\ttype: 'string'\r\n\t\t},\r\n\r\n\t\tlastname:{\r\n\t\t\ttype: 'string'\r\n\t\t},\r\n\t\t\r\n\t\tusername:{\r\n\t\t\ttype: 'string',\r\n\t\t\tunique: true\r\n\t\t},\r\n\r\n\t\temail:{\r\n\t\t\ttype: 'email',\r\n\t\t\tunique: true\r\n\t\t},\r\n\r\n\t\tactive:{\r\n\t\t\ttype: 'boolean',\r\n\t\t\tdefaultsTo: false\r\n\t\t},\r\n\t\t\r\n\t\tadmin:{\r\n\t\t\ttype: 'boolean',\r\n\t\t\tdefaultsTo: false,\r\n\t\t},\r\n\r\n\t\tpassports : { \r\n\t\t\tcollection: 'passport',\r\n\t\t\tvia: 'user' \r\n\t\t},\r\n\r\n\t\tpermissions: {\r\n\t\t\tcollection: 'permission',\r\n\t\t\tvia: 'user'\r\n\t\t},\r\n\r\n\t\tactivate: {\r\n\t\t\tmodel: 'activationuuid'\r\n\t\t},\r\n\r\n\t\tcells: {\r\n\t\t\tcollection: 'cell',\r\n\t\t\tvia: 'users',\r\n\t\t\tdominant:true\r\n\t\t},\r\n\r\n\t\tlists: {\r\n\t\t\tcollection: 'list',\r\n\t\t\tvia: 'users'\r\n\t\t}\r\n\t}\r\n\r\n};\r\n```\r\n\r\nList Model:\r\n```\r\n/**\r\n* List.js\r\n*\r\n* @description :: TODO: You might write a short summary of how this model works and what it represents here.\r\n* @docs        :: http://sailsjs.org/#!documentation/models\r\n*/\r\n\r\nmodule.exports = {\r\n\r\n  attributes: {\r\n\r\n  \tname:{\r\n  \t\ttype:'string',\r\n  \t\trequired: true\r\n  \t},\r\n\r\n  \tusers:{\r\n  \t\tcollection:'user',\r\n  \t\tvia:'lists'\r\n  \t},\r\n\r\n  \tdevelopments:{\r\n  \t\tcollection:'development',\r\n  \t\tvia:'lists'\r\n  \t},\r\n\r\n  \tdeveloper:{\r\n  \t\tmodel:'developer'\r\n  \t},\r\n\r\n//contains id of development and permissions level\r\n//denotes if prices is shared and if by unit.\r\n  \tpermissions:{\r\n  \t\ttype:'json'\r\n  \t},\r\n\r\n  \tcells:{\r\n  \t\tcollection: 'cell',\r\n  \t\tvia: 'lists'\r\n  \t}\r\n\r\n  }\r\n};\r\n\r\n```\r\n\r\nSuggestions or anything in the code that seems odd please do let me know."},"comment":{"url":"https://api.github.com/repos/balderdashy/sails/issues/comments/97162665","html_url":"https://github.com/balderdashy/sails/issues/1797#issuecomment-97162665","issue_url":"https://api.github.com/repos/balderdashy/sails/issues/1797","id":97162665,"user":{"login":"sgress454","id":553428,"avatar_url":"https://avatars.githubusercontent.com/u/553428?v=3","gravatar_id":"","url":"https://api.github.com/users/sgress454","html_url":"https://github.com/sgress454","followers_url":"https://api.github.com/users/sgress454/followers","following_url":"https://api.github.com/users/sgress454/following{/other_user}","gists_url":"https://api.github.com/users/sgress454/gists{/gist_id}","starred_url":"https://api.github.com/users/sgress454/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgress454/subscriptions","organizations_url":"https://api.github.com/users/sgress454/orgs","repos_url":"https://api.github.com/users/sgress454/repos","events_url":"https://api.github.com/users/sgress454/events{/privacy}","received_events_url":"https://api.github.com/users/sgress454/received_events","type":"User","site_admin":false},"created_at":"2015-04-28T18:26:29Z","updated_at":"2015-04-28T18:26:29Z","body":"Looks like `remove` is working.  It's just that it doesn't alter the original object (in this case `l`) the way that you're expecting.  If you use the result from the `save` command, you'll see it's correct:\r\n\r\n```\r\nList.findOne({id:listID}).populate('users').exec(function (err,l){\r\n      if(err){ return console.log(err); }\r\n        if(!l){ return res.json('What'); }\r\n          else {\r\n            l.users.remove(userID);\r\n            l.save(function (err, updatedList){\r\n               console.log(updatedList);\r\n            });\r\n          }\r\n});\r\n```\r\n\r\n`updatedList` will have the correct number of users in it."}}