TypeError: _.pluck is not a function in sails-ember-rest/templates/actions/find
Closed this issue · 3 comments
Hi - and many thanks for this code. I'm loving Sails and Ember but I'm not experienced enough to think through and implement on my own all that you've done here.
I was trying something out for a new app, and this came up.
Ember:
console.log('Attempting to connect...'); let sailsSocket = io.sails; sailsSocket.useCORSRouteToGetCookie = false let connection = sailsSocket.connect('http://localhost:1337'); connection.get('/registrations', [], function (resData, jwres){ console.log(resData); });
But this was crashing Sails with a message:
Sails in terminal
TypeError: _.pluck is not a function at actionUtil.populateIndexes (/Users/leonidas/Sites/nautilus/nautilus-sails/node_modules/sails-ember-rest/templates/actions/find.js:50:48)
P.S.
I did a little searching, and found this:
So I went ahead and did the same in sails-ember-rest/templates/actions/find.js:50:48, i.e. changed
if (req._sails.hooks.pubsub && req.isSocket) { Model.subscribe(req, _.pluck(matchingRecords, Model.primaryKey)); ...
to
if (req._sails.hooks.pubsub && req.isSocket) { Model.subscribe(req, _.map(matchingRecords, Model.primaryKey)); ...
which seems to have solved the problem. Thought this might be useful.
Hi Ikossis!
Thanks for finding this! This deprecated function call is probably here because Sails used to use an older version of lodash. I will scrub the codebase for all calls to _.pluck and push out an update patch to npm today.
Out of curiosity, can you please list the version of Sails, Waterline, and Lodash your project is currently using?
This should be fixed in 1.0.11 on npm!
Closing this issue as it should be solved in 1.0.11.