Last active
October 19, 2016 00:08
-
-
Save ef4/def026cf7b03a2e1e183 to your computer and use it in GitHub Desktop.
route vs resource in Ember route map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "route" and "resource" are almost interchangeable. Both of these work fine: | |
this.route('people', function(){ | |
this.route('person', {path: '/:person_id'}) | |
}) | |
this.route('people', function(){ | |
this.resource('person', {path: '/:person_id'}) | |
}) | |
// And they both establish the same URLs, namely | |
// - /people | |
// - /people/:person_id | |
// The only difference is how their Routes get named. The first example above will use: | |
// app/routes/people.js | |
// app/routes/people/person.js | |
// whereas the second one will use: | |
// app/routes/people.js | |
// app/routes/person.js | |
// For new apps using ember-cli, I would recommend using 'route' for everything. It's | |
// simple and makes your file hierarchy on disk match your URL hierarchy in router.js. | |
// 'resource' exists mostly for historical reasons, but as the API has evolved it is not | |
// so important anymore and it will be logical if it gets deprecated eventually. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment