@@ -184,19 +184,29 @@ export default class PostRoute extends Route {
184
184
}
185
185
```
186
186
187
- 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:
187
+ In the ` model ` hook for routes with dynamic segments, it's your job to
188
+ turn the ID (something like ` 47 ` or ` post-slug ` ) into a model that can
189
+ be rendered by the route's template.
190
+
191
+ In the above example, we could use the post's ID (` params.post_id ` ) as
192
+ an argument to EmberData's ` findRecord ` method.
193
+
194
+ ``` javascript {data-filename=app/routes/post.js}
195
+ import Route from ' @ember/routing/route' ;
196
+ import { service } from ' @ember/service' ;
188
197
189
- ``` js
190
- model (params ) {
191
- return this .store .findRecord (' post' , params .post_id );
198
+ export default class PostRoute extends Route {
199
+ @service store;
200
+
201
+ model (params ) {
202
+ return this .store .findRecord (' post' , params .post_id );
203
+ }
192
204
}
193
205
```
194
206
195
- In the ` model ` hook for routes with dynamic segments, it's your job to
196
- turn the ID (something like ` 47 ` or ` post-slug ` ) into a model that can
197
- be rendered by the route's template. In the above example, we use the
198
- post's ID (` params.post_id ` ) as an argument to EmberData's ` findRecord `
199
- method.
207
+ Note that currently, if ` model ` is not specified, Ember will attempt
208
+ to automatically find a store and use it for lookup. This behavior
209
+ is a common source of confusion and will be removed in future Ember versions.
200
210
201
211
### Linking to a dynamic segment
202
212
@@ -299,7 +309,7 @@ import RSVP from 'rsvp';
299
309
300
310
export default class AlbumRoute extends Route {
301
311
@service store;
302
-
312
+
303
313
model ({ album_id }) {
304
314
return RSVP .hash ({
305
315
album: this .store .findRecord (' album' , album_id),
0 commit comments