3
votes

In an application I use the latest canary versions for Ember and Ember Data. I have the following router:

this.resource('articles', {path: '/articles'}, function() { 
    this.resource('article', {path: '/:article_id'});
});

In the ArticlesController I specify some queryParams:

queryParams: ['category', 'search'],
category: '1', // defaults to 1
searchTerm: "",    

In my ArticlesRoute I specify a model refresh and the model:

queryParams: {
    category: {
        refreshModel: true
    }
},

model: function(params) {
    // here I do use the params to return articles based on category and/or searchTerm
}

So far so good, all code above works perfect. However when I do a this.transitionTo('article', articleObject) or this.transitionToRoute('article', articleObject) in my application I get the following error:

Error: You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route article
    at Object.__exports__.default.subclass.createParamHandlerInfo (http://localhost:8000/vendor/ember/index.js:44242:21)
    at Object.__exports__.default.subclass.applyToHandlers (http://localhost:8000/vendor/ember/index.js:44121:37)
    at Object.__exports__.default.subclass.applyToState (http://localhost:8000/vendor/ember/index.js:44088:21)
    at Object.Router.transitionByIntent (http://localhost:8000/vendor/ember/index.js:43312:33)
    at Object.Router.refresh (http://localhost:8000/vendor/ember/index.js:43459:21)
    at EmberObject.extend.refresh (http://localhost:8000/vendor/ember/index.js:22616:35)
    at EmberObject.extend._actions.queryParamsDidChange (http://localhost:8000/vendor/ember/index.js:22328:22)
    at Object.triggerEvent (http://localhost:8000/vendor/ember/index.js:24563:38)
    at trigger (http://localhost:8000/vendor/ember/index.js:44812:16)
    at fireQueryParamDidChange (http://localhost:8000/vendor/ember/index.js:43612:9) index.js:14220
Uncaught Error: Assertion Failed: Error: You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route article index.js:3658

This strange error only happens when I first clicked a Category so the queryParam category is changed, and then fire a transitionTo to an article.

I have tried to use the debugger; statement to get the source of the error. However it seems that is an event that calls this error. When searching the sourcecode I found that the error originates from line 44242 of ember.js.

Does anyone know why this error happen after I have transitioned to a non query-params-new route?

Edit: now in Github too: https://github.com/emberjs/ember.js/issues/5070 (comment on Github) JSBin: http://emberjs.jsbin.com/yiquyupa

1

1 Answers

3
votes

I ran into almost the same issue in an afterModel callback where the parent route/controller has queryParams.

I found that if you just pass the queryParams from the transition argument (not the queryParams argument which is null/undefined) into Route.transitionTo / Route.replaceWith then the transition completes.

Example:

 afterModel: function(model, transition, queryParams) {
    // FIXME: unresolved Ember issue https://github.com/emberjs/ember.js/issues/5070
    this.replaceWith('another.route', model, { queryParams: transition.queryParams});
 }

I don't know why this happens, but queryParams is still a relatively new feature and still has some rough edges.