Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p.66 create an articles new controller #17

Open
mfromin opened this issue Aug 19, 2015 · 1 comment
Open

p.66 create an articles new controller #17

mfromin opened this issue Aug 19, 2015 · 1 comment

Comments

@mfromin
Copy link

mfromin commented Aug 19, 2015

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 (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;
        }
    }
});
@lundie
Copy link

lundie commented Nov 19, 2015

I've noticed the same issue. Was throwing me for a loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants