irlnathan / sails-generate-scaffold

This is a generator for creating a scaffold (CRUD) for a Sails Project
MIT License
42 stars 26 forks source link

Error on last version of sails.js #15

Open mjsorribas opened 8 years ago

mjsorribas commented 8 years ago

When i tried $ sails generate scaffold services //for example.. i obtain this error: nodemodules/sails-generate-scaffold/Generator.js:102 var modelAttributeNames = .pluck(scope.modelAttributes, 'name'); TypeError: _.pluck is not a function at Object.module.exports.before (/.../node_modules/sails-generate-scaffold/Generator.js:102:33) at generate (/usr/lib/node_modules/sails/node_modules/sails-generate/lib/generate.js:73:13) at module.exports (/usr/lib/node_modules/sails/node_modules/sails-generate/lib/index.js:112:3) at Command.module.exports (/usr/lib/node_modules/sails/bin/sails-generate.js:107:10) at Command.listener (/usr/lib/node_modules/sails/node_modules/commander/index.js:301:8) at emitTwo (events.js:87:13) at Command.emit (events.js:172:7) at Command.parseArgs (/usr/lib/node_modules/sails/node_modules/commander/index.js:615:12) at Command.parse (/usr/lib/node_modules/sails/node_modules/commander/index.js:458:21) at Object. (/usr/lib/node_modules/sails/bin/sails.js:145:9)

SamyOteroGlez commented 8 years ago

I had the same problem. Any advice?

SamyOteroGlez commented 8 years ago

I resolve this error TypeError: _.pluck is not a function by this:

1 - path_to_my_server/sailsTest/node_modules/sails-generate-scaffold/

npm install underscore

2 - add in the top of Generator.js

_.pluck = require('underscore');

but then comes another in this lines:

compiledNewFlash = compiledNewFlash.replace(/ERBstart/g, '<%') compiledNewFlash = compiledNewFlash.replace(/ERBend/g, '%>')

it said that replace is not a function.

I also resolve that by change in all coincidences:

compiledNewFlash = compiledNewFlash.replace(new RegExp(/ERBstart/g, 'g'), '<%');

marlonscalabrin commented 8 years ago

Solution:

npm install underscore

Insert following code in node_modules/sails-generate-scaffold/Generator.js line 12:

_.pluck = require('underscore');
my_template = _.template;
_.template = function(arg1, arg2) {
  return my_template(arg1)(arg2);
}

or

npm install -S "git+https://github.com/marlonscalabrin/sails-generate-scaffold.git"

gerardoog59 commented 8 years ago

Solution: Change this line var modelAttributeNames = .pluck(scope.modelAttributes, 'name'); by this line var modelAttributeNames = .map(scope.modelAttributes, 'name');

ernaneluis commented 7 years ago

yes facing the same problem as well but @marlonscalabrin solution fixed the problem. thx bro!

moda20 commented 6 years ago

nearly 3 years and this problem is still not fixed, sails is dead.

makstaks commented 5 years ago

nearly 3 years and this problem is still not fixed, sails is dead.

@moda20 this is a community project, it is not part of the core SailsJS project which is very active: https://github.com/balderdashy/sails/

I found a fork of this project here: https://github.com/e9labs/sails-generate-scaffold which solves the problem.