EmberJS: "Error missing: more context objects passed than there are dynamic segments for the route"

I have two routes, one of which uses a dynamic segment:

App.Router.map(function() {
    this.resource('books');
    this.resource('book', {
        path: "/book/:book_uid"
    })
});

      

When I try the {{link-to 'book' abook.uid}} helper in the Books template, I get the error:

Search error: More context objects passed than there are dynamic segments for route: book

This is the model for the book:

App.Book = DS.Model.extend({
    book_id: DS.attr()      
});

      

and this is how I define the route for the book:

 App.BookRoute = Ember.Route.extend({
            model: function(params) {
                return this.store.find('book', params.book_uid);
            },
            serialize: function(model) {
                return {
                    book_uid: model.get('uid')
                };
            } 
});

      

Any customs there, who can look see ???

+3


source to share


1 answer


When the helper is link-to

used inline, the first parameter is used as the link text, and the rest of the arguments are used as your route route.

So, in your case, you have to pass three arguments to it like this:

{{link-to 'Show book' 'book' abook.uid}}

      



Or use the block form like this:

{{#link-to 'book' abook.uid}}
  Show book
{{/link-to}}

      

+2


source







All Articles