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 trial

JavaScript Ember.js Ember Data Creating and Deleting Records

josefina terrera
josefina terrera
16,506 Points

'save' button

I can't seem to make the 'save' button work. Is the finished project uploaded somewhere? Or, am I missing something here:

Blogger.NewPostController = Ember.Controller.extend({
    actions: {
        save: function() {
            var newPost = this.store.createRecord('post', {
                title: this.get('title'),
                body: this.get('body')
            });
            newPost.save();
            this.transitionToRoute('posts');
        }
    }
});

Thanks!

8 Answers

Joe Cuanan
Joe Cuanan
15,564 Points

Hey Josefina,

I got stuck on this too and did some digging:

http://discuss.emberjs.com/t/ember-issue-with-1-8-0-beta-3-and-1-8-0-beta-4/6429

I updated my ember-data.js to the most recent version and it works fine now. I'm not 100% pleased with this solution as the instructor indicates that his code should work as long as we use the same library versions as him, but evidently that is not the case. I'm going to continue looking into it to see if I can get it to work using the Ember data version from the course.

Happy coding! Joe

Thanks, Joe. I rewatched the video to make sure I had my code right and I was getting "Uncaught TypeError: undefined is not a function" in the JavaScript Console until I updated the ember-data.js to the latest version on http://builds.emberjs.com/tags/v1.0.0-beta.11/ember-data.js.

J. M.
J. M.
15,389 Points

I had the same issue.

Thanks.

Michael Kaiser-Nyman
STAFF
Michael Kaiser-Nyman
Treehouse Guest Teacher

I'm not sure why Beta 10 is causing an issue here, but I did make a mistake - I should have said to use Beta 11. Beta 10 has lots of problems. Sorry for the trouble!

Michael Kaiser-Nyman
STAFF
Michael Kaiser-Nyman
Treehouse Guest Teacher

Hi folks! I've been trying a few different versions of Ember Data to see if I can figure out the problems you're having, but I can't see to track them down. Would one or both of my mind putting your code on Github (or anywhere else I can access it) so that I can see what might be going wrong? Thanks!

Aslam Najeebdeen
Aslam Najeebdeen
617 Points

Had the same issue. Thanks Joe and Blake!

Thanks Joe, and Blake. man this got me wasting alot of time.

I had the same problem. The ember-data.js update worked!

Thanks!

W. Perry Wortman
W. Perry Wortman
22,087 Points

Hi all,

Same issue here, an error message saying "Uncaught TypeError: undefined is not a function". Beta 11 was unfortunately not fixing the problem. But updating to Beta 15 and including the ember-data.js.map file did finally solve the issue for me.

Despite the dependency difficulties, really quite a good course on Ember.js. Thank you for putting it together, Michael!