Skip to content

Commit

Permalink
Remove documentation for implicit route model
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet committed Mar 7, 2023
1 parent b2892f3 commit 33504de
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions guides/release/routing/specifying-a-routes-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,26 @@ export default class PostRoute extends Route {
}
```

If you do not define a model hook for a route, it will default to using EmberData to look up the record, as shown below:
In the `model` hook for routes with dynamic segments, it's your job to
turn the ID (something like `47` or `post-slug`) into a model that can
be rendered by the route's template.

In the above example, we could use the post's ID (`params.post_id`) as
an argument to EmberData's `findRecord` method.

```javascript {data-filename=app/routes/post.js}
import Route from '@ember/routing/route';
import { service } from '@ember/service';

export default class PostRoute extends Route {
@service store;

```js
model(params) {
return this.store.findRecord('post', params.post_id);
model(params) {
return this.store.findRecord('post', params.post_id);
}
}
```

In the `model` hook for routes with dynamic segments, it's your job to
turn the ID (something like `47` or `post-slug`) into a model that can
be rendered by the route's template. In the above example, we use the
post's ID (`params.post_id`) as an argument to EmberData's `findRecord`
method.

### Linking to a dynamic segment

There are two ways to link to a dynamic segment from an `.hbs` template using [`<LinkTo>`](../../templates/links/).
Expand Down Expand Up @@ -299,7 +305,7 @@ import RSVP from 'rsvp';

export default class AlbumRoute extends Route {
@service store;

model({ album_id }) {
return RSVP.hash({
album: this.store.findRecord('album', album_id),
Expand Down

0 comments on commit 33504de

Please sign in to comment.