borrowers
borrowers copied to clipboard
p.66 create an articles new controller
p.66 of my PDF states this:
Tasks
Create an articles new controller and validate that the model includes description.
If it is valid, let the action bubble to the route. Otherwise, set an errorMessage.
When I look at the code commits for this portion of the tutorial I would expect to see a file:
app/controllers/articles/new.js
...but I don't see one at all. Am I missing the intent of the task on p 66 of the PDF? When I click the link to look at the changes introduced (https://github.com/abuiles/borrowers/commit/262f8c1) there is no articles controller of any type. The final project also does not have a new.js
controller for articles.
What I did based on the task is to create the file app/controllers/articles/new.js
and put the following code in there:
import Ember from 'ember';
export default Ember.Controller.extend({
hasDescription: Ember.computed.notEmpty('model.description'),
isValid: Ember.computed.and(
'hasDescription'
),
actions: {
save: function () {
console.log('+- save action in articles/new controller');
if (this.get('isValid')) {
return true;
} else {
this.set('errorMessage', 'You have to fill in all the fields');
return false;
}
},
cancel: function () {
return true;
}
}
});
I've noticed the same issue. Was throwing me for a loop.