简体   繁体   中英

'Ember generate resource' command end up adding this.route() to router.js

I am going through a tutorial on ember-cli and faced some strange behavior:
To generate a new resource named 'friends' I am running an ember-cli command:

$ ember generate resource friends

And the generator creates all the required files, plus in the app/router.js it adds the following:

...
Router.map(function() {
  this.route('friends');
});
...

and I expect it to create (and this is mentioned in the tutorial):

  this.resource('friends', function(){ });

instead of

  this.route('friends');

So i can not understand, what am I doing wrong? Or maybe something changed in ember-cli routes/resources generator since this tutorial were released and this behavior is now normal?

Thanks in advance,
Gleb.

Prior to ember 1.7 resources were used due to their ability to reset the namespace and nest routes, routes could not be nested at the time.

Since ember 1.7+ routes can be nested and you can reset the namespace by setting this.route('my-route', { path: '/mypath', resetNamespace: true } function() {});

The blueprint you are using was last modified on april 24 to reflect the deprecation and use routes instead of resources.

For more information give the following article a read.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM