Dynamic segments: why item_id does not behave the same as itemId


#1

Well first I will say that I am a little bit upset with Ember lack of documentation (or up-to-date information) and clear explanations (an advice to people who write documentations : people who read it do not have the same knowledge as you).

I fell now better since I wrote it :wink:

I have a router like this:

this.resource('profils', { path: '/' } , function() {
    this.resource('profil', { path: ':profil_id' });
});

It does not work (see Failing dynamic segment)

When I use this:

this.resource('profil', { path: ':profilId' });

It works (See Working dynamic segment) although the Ember Guide (Defining your routes) clearly states we should use _id.

Does anyone have an explanation ? And what documentation should we follow ?

Is the first way correct and, if yes, what did I made wrong ?


#2
{{#linkTo 'profil'}}{{name}}{{/linkTo}}

Since you’re using :profil_id, to what model are You linking here? :wink: Use…

{{#linkTo 'profil' this}}{{name}}{{/linkTo}}

Edit: I would advise You to use full emberjs, instead of min. version. Difference between debug messages is obvious:

Uncaught TypeError: Cannot read property ‘__ember1376604573025_meta’ of undefined vs Assertion failed: Cannot call get with ‘id’ on an undefined object.


#3

Using this make it work, thanks !

Sorry, I still don’t understand why. I expected profil_id to link to an App.Profil object. Apparently documentation was updated and gives an example that is different from what I had first. Well, ok I should have give a look since :wink:

I already use full emberjs and I don’t know why my object is undefined without this.

I guess I should re-read all the docs ! "=-|