Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Commit

Permalink
Fix routing mistakes and remove references to this.resource
Browse files Browse the repository at this point in the history
  • Loading branch information
trek committed Mar 30, 2015
1 parent 14f7642 commit fb7f74b
Show file tree
Hide file tree
Showing 18 changed files with 189 additions and 442 deletions.
24 changes: 5 additions & 19 deletions source/concepts/naming-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Consider this router definition:

```javascript
export default Ember.Router.extend().map(function(){
this.resource('post', { path: '/posts/:post_id' });
this.route('post', { path: '/posts/:post_id' });
});
```

Expand Down Expand Up @@ -200,21 +200,12 @@ You can nest routes under a `resource`.

```javascript
export default Ember.Router.extend().map(function(){
this.resource('posts', function() { // the `posts` route
this.route('posts', function() { // the `posts` route
this.route('favorites'); // the `posts.favorites` route
this.resource('post'); // the `post` route
this.route('post'); // the `posts.post` route
});
});
```

A **resource** is the beginning of a route, controller, or template
name. Even though the `post` resource is nested, its route is named
`App.PostRoute`, its controller is named `App.PostController` and its
template is `post`.

When you nest a **route** inside a resource, the route name is added
to the resource name, after a `.`.

Here are the naming conventions for each of the routes defined in
this router:

Expand Down Expand Up @@ -247,11 +238,6 @@ this router:
</tr>
</table>

The rule of thumb is to use resources for nouns, and routes for
adjectives (`favorites`) or verbs (`edit`). This ensures that
nesting does not create ridiculously long names, but avoids
collisions with common adjectives and verbs.

## The Index Route

At every level of nesting (including the top level), Ember.js
Expand Down Expand Up @@ -289,7 +275,7 @@ A nested router like this:

```app/router.js
export default Ember.Router.extend().map(function(){
this.resource('posts', function() {
this.route('posts', function() {
this.route('favorites');
});
});
Expand All @@ -300,7 +286,7 @@ Is the equivalent of:
```app/router.js
export default Ember.Router.extend().map(function(){
this.route('index', { path: '/' });
this.resource('posts', function() {
this.route('posts', function() {
this.route('index', { path: '/' });
this.route('favorites');
});
Expand Down
4 changes: 2 additions & 2 deletions source/controllers/dependencies-between-controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ router as an example:
var Router = Ember.Router.extend({});

Router.map(function() {
this.resource("post", { path: "/posts/:post_id" }, function() {
this.resource("comments", { path: "/comments" });
this.route("post", { path: "/posts/:post_id" }, function() {
this.route("comments", { path: "/comments" });
});
});

Expand Down
4 changes: 2 additions & 2 deletions source/models/finding-records.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ Ember deal with figuring out whether a network request is needed or not.
var Router = Ember.Router.extend({});

App.Router.map(function() {
this.resource('posts');
this.resource('post', { path: ':post_id' });
this.route('posts');
this.route('post', { path: ':post_id' });
});

export default Router;
Expand Down
2 changes: 1 addition & 1 deletion source/routing/asynchronous-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ arrays, the transition will complete immediately. But if the `model` hook
if a promise was provided as an argument to `transitionTo`), the transition
will pause until that promise fulfills or rejects.

**Note:** The router considers any object with a `then` method
The router considers any object with a `then` method
defined on it to be a promise.

If the promise fulfills, the transition will pick up where it left off and
Expand Down
Loading

0 comments on commit fb7f74b

Please sign in to comment.