Skip to content

Commit

Permalink
[RFC-774] Remove documentation for implicit route model (#1907)
Browse files Browse the repository at this point in the history
Co-authored-by: Jen Weber <j@jenweber.me>
  • Loading branch information
wagenet and jenweber authored Jun 29, 2023
1 parent 90e1c7a commit ba3940a
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions guides/release/routing/specifying-a-routes-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,29 @@ 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';

```js
model(params) {
return this.store.findRecord('post', params.post_id);
export default class PostRoute extends Route {
@service store;

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.
Note that currently, if `model` is not specified, Ember will attempt
to automatically find a store and use it for lookup. This behavior
is a common source of confusion and will be removed in future Ember versions.

### Linking to a dynamic segment

Expand Down Expand Up @@ -299,7 +309,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 ba3940a

Please sign in to comment.