the following code snippet in the tutorial for Pieces (http://apostrophecms.org/docs/tutorials/getting-started/reusable-content-with-pieces.html) gives the type error : self[name] is not a function - on line 1031 of lib/modules/apostrophe-docs/lib/cursor.
The error happens when clicking on the save button for adding a new person or saving the piece.
I understand this may happen because the object is not actually what I am thinking it is or because it´s returning a null value. Both seem unlikely.
As I am following the tutorial step by step I have only browsed through the cursor part.
The people.index.js file is the following:
module.exports = {
extend: 'apostrophe-pieces',
name: 'person',
label: 'Person',
pluralLabel: 'People',
addFields: [
{
name: 'title',
label: 'Full Name',
type: 'string',
required: true,
contextual: true
},
{
name: 'firstName',
label: 'First Name',
type: 'string',
required: true
},
{
name: 'lastName',
label: 'Last Name',
type: 'string',
required:true
},
{
name: 'body',
label: 'Biography',
type: 'area',
options: {
widgets: {
'apostrophe-rich-text': {
controls: [ 'Bold', 'Italic', 'Link', 'Unlink' ]
},
'apostrophe-images': {}
}
}
},
{
name: 'phone',
label: 'Phone',
type: 'string'
},
{
name: 'thumbnail',
label: 'Thumbnail',
type: 'singleton',
widgetType: 'apostrophe-images',
options: {
limit: 1,
minSize: [ 200, 200 ],
aspectRatio: [ 1, 1 ]
}
}
],
arrangeFields: [
{
name: 'contact',
label: 'Contact',
fields: [ 'firstName', 'lastName', 'phone' ]
},
{
name: 'admin',
name: 'Admin',
fields: [ 'slug', 'published', 'tags' ]
},
{
name: 'content',
name: 'Biographical',
fields: [ 'thumbnail', 'body' ]
}
],
construct: function(self, options) {
var superPushAssets = self.pushAssets;
self.pushAssets = function() {
superPushAssets();
self.pushAsset('stylesheet', 'always', { when: 'always' });
};
},
construct: function(self, options) {
self.beforeSave = function(req, piece, options, callback) {
piece.title = piece.firstName + ' ' + piece.lastName;
return callback();
};
}
};