Uncaught More context objects were passed than there are dynamic segments for the route: post

I’m trying to follow this basic Ember.js tutorial but having no luck with the “posts” model. I have everything set up according to the demonstration, however I am getting the error:

Uncaught More context objects were passed than there are dynamic segments for the route: post

Since this is the first time I’ve ever worked with an Ember.js app, I honestly have no clue what this means. Any help (literally anything) would be greatly appreciated.

Here is my App.js

App = Ember.Application.create();

App.Store = DS.Store.extend({
    adapter: 'DS.FixtureAdapter'

App.Router.map(function () {
    this.resource('posts', function() {
        this.resource('post', { path:'post_id'})

App.PostsRoute = Ember.Route.extend({
    model: function () {
        return App.Post.find();

App.Post = DS.Model.extend({
    title: DS.attr('string'),
    author: DS.attr('string'),
    intro: DS.attr('string'),
    extended: DS.attr('string'),
    publishedAt: DS.attr('date')

App.Post.FIXTURES = [{
        id: 1,
        title: "Rails in Omakase",
        author: "d2h",
        publishedAt: new Date('12-27-2012'),
        intro: "Blah blah blah blah",
        extended: "I have no clue what extended means"
    }, {
        id: 2,
        title: "Second post",
        author: "second author",
        publishedAt: new Date('1-27-2012'),
        intro: "second intro",
        extended: "Second extended"

And here is the html for the posts.

<script type="text/x-handlebars" id="posts">
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span3">
                <table class="table">
                    <tr><th>Recent Posts</th></tr>
                {{#each model}}
                    {{#linkTo 'post' this}}{{title}} <small class="muted">by {{author}}</small>{{/linkTo}}
            <div class="span9">
<script type="text/x-handlebars" id="post">
    <h2> by {{author}} <small class="muted">{{publishedAt}}</small></h2>


    <div class="intro">

    <div class="below-the-fold">

I think you meant to have a route specified.

this.resource('posts', function() {
    this.route('post', { path:'/post/:post_id'})

The error sounds like you are passing something like post/12 and you don’t have a dynamic segment specified(written as :post_id) The : is the important point that specifies a dynamic segment.

Read More:   How to post a tweet using Codebird PHP from pop-up window

Taken from the Ember.js documentation

The accepted answer works.

However, given where the op is in the example, the more correct fix is to leave the following alone:


and add this below it:

this.resource('post', { path: '/post/:post_id'});

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts