ember.js: ember 2.10 undefined route dynamic segment no longer working.
This looks more like a unsupported feature than a bug but I thought I would log it.
When upgrading from 2.9.1 to 2.10 I ran into the following exception.
"Assertion Failed: You attempted to define a `{{link-to "timecards"}}` but did not pass the parameters required for generating its dynamic segments. You must provide param `login` to `generate`."
#app/router.js
this.route('timecards', {path: '/timecards/:login'}, function() {
this.route('index', { path: '/' });
this.route('timecard-day', {path: '/day/:date'});
this.route('pay-period', {path: '/pay-period/:date'});
});
#app/routes/timecards.js #model hook
model(params) {
let login = params.login || this.get('currentUser.login');
return this.store.peekAll('user').findBy('login', login);
}
It was quite handy to use a optional dynamic segment on the parent route to load a default user model rather than having to load it for each individual child routes.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 20
- Comments: 22 (12 by maintainers)
This is blocking 2.10 and 2.11 for us. Happy to attempt a fix if someone can confirm this is a regression.
Long shot here, but I ran into this issue when accidentally overriding the native
Objectwith Ember’s Object class via something like:const { Object } = Ember;This was causing my model hook (where
Object.createis called) to fail and, for some reason, the exception thrown mentioned dynamic segments not being present. I think this is similar to what @alvincrespo mentions in his comment above.@brunowego Yeah that’s the same error I was getting. In our case it seems that this is more of a misleading exception than an actual bug.
Running into this same issue today 👎
In case anyone runs into this issue, could possibly be this:
Note that I am importing
Contollerincorrectly. It should beimport Controller from 'ember-controller';. This is if you are using ember-cli-shims, which is what my current project is using. I was lost on this for about an hour before I gave up, came back and saw clearly what I was doing wrong.Closing for now, feel free to re-open if you can reproduce in the current release of Ember.
@lrdiv this was also happening to me, good catch! ✌️
What I was doing was to destructure Ember and precisely override the native
Objectwith what was otherwise anEmber.Object. So I changed the name into something likeconst EmberObject = Ember.Objectin the declaration and usage and all went the right way. I wouldn’t call it a bug-bug either, so I agree with you on pretty much everything you wrote above 😜I’m fairly sure you can still do this by passing undefined and implementing a custom serialize hook.
The error message added here is a pretty big win for folks in general, and I’d prefer to keep it around if possible…