Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChristopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 PointsES6 Question
I tried to refactor Andrews code and I have this:
instanceMethods: {
publishedAt: () => dateFormat(this.createdAt, "dddd, mmmm dS, yyyy, h:MM TT"),
shortDescription: () => this.body.length > 30 ? this.body.substr(0, 30) + "..." : this.body,
}
but when I go to the home page i get this error and assuming this is the issue---anyone see a problem with formatting here?
TypeError: C:\Users\crstu\Desktop\JSPROJ\sequelize_blog-start\views\articles\by_line.jade:4 2| = article.author 3| | |
4| = article.publishedAt()
3 Answers
Christopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 PointsSo it turns out that the formatting for instance methods and class methods have changed with Sequelize 4. Treehouse needs to update this video.
Steven Parker
231,269 PointsBe sure to let the staff know, using the feedback method described on the Support page.
Ben Zuba
13,575 PointsRan into this same problem new update in sequelize 4. this syntax worked for me
module.exports = (sequelize, DataTypes) => {
var Article = sequelize.define('Article', {
title: DataTypes.STRING,
author: DataTypes.STRING,
body: DataTypes.TEXT
}, {});
Article.associate = function(models) {
// associations can be defined here
};
Article.prototype.publishedAt = function(){
return dateFormat(this.createdAt, "dddd, mmmm dS, yyyy, h:MM TT");
};
Article.prototype.shortDescription = function(){
return this.body.length > 30 ? this.body.substr(0, 30) + "..." : this.body;
};
return Article;
};
Jean-Yves Le Cabellec
Full Stack JavaScript Techdegree Graduate 17,341 PointsThanks @ben zuba and @Christopher Stuart
Christopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 PointsChristopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 Pointsleft part out--it says article.publishedAt is not a function