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

Can't get new posts to save

I have been following along the Ember course and it is great. Had my fair share of challenges that I was able to figure out, except this one. Here is my code that is in posts.js

Blogger.PostsRoute = Ember.Route.extend({ model : { function(){ return this.store.find('post', params.post_id); console.log('post saved'); }; } });

And here is what I have in new-post.js (controller)

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'); } } });

I have a console error that says posts.js has an 'unexpected token' but when digging deep I can't find anything wrong. Everything works until I try to save the post, nothing happens.

When I go to /posts I get these errors in my console

ember.js:15373 Error: Assertion Failed: The URL '/posts' did not match any routes in your application at new Error (native) at Error.EmberError (http://dev.ember-prac.com/libs/ember.js:14251:23) at Object.Ember.assert (http://dev.ember-prac.com/libs/ember.js:3865:15) at http://dev.ember-prac.com/libs/ember.js:26502:17 at tryCatch (http://dev.ember-prac.com/libs/ember.js:47307:16) at invokeCallback (http://dev.ember-prac.com/libs/ember.js:47319:17) at http://dev.ember-prac.com/libs/ember.js:49218:13 at http://dev.ember-prac.com/libs/ember.js:29435:9 at DeferredActionQueues.invoke (http://dev.ember-prac.com/libs/ember.js:679:18) at Object.DeferredActionQueues.flush (http://dev.ember-prac.com/libs/ember.js:749:15)ember.js:15373 logToConsoleember.js:29460 RSVP.onerrorDefaultember.js:47986 exports.default.triggerember.js:48998 Promise._onerrorember.js:47229 publishRejectionember.js:29435 (anonymous function)ember.js:679 DeferredActionQueues.invokeember.js:749 DeferredActionQueues.flushember.js:135 Backburner.endember.js:190 Backburner.runember.js:18223 runember.js:2542 runInitializejquery-1.11.1.js:3119 firejquery-1.11.1.js:3231 self.fireWithjquery-1.11.1.js:3443 jQuery.extend.readyjquery-1.11.1.js:3474 completed ember.js:3865 Uncaught Error: Assertion Failed: Error: Assertion Failed: The URL '/posts' did not match any routes in your application

I have a feeling it is something minor that I am missing but for the life of me I cannot figure it out! PLEASE HELP!

-Thanks

Kelly

1 Answer

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

You'll need to add a new entry to your router in addition to creating your route.