Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC-774] Remove documentation for implicit route model #1907

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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