Skip to content

Commit ba3940a

Browse files
wagenetjenweber
andauthored
[RFC-774] Remove documentation for implicit route model (#1907)
Co-authored-by: Jen Weber <[email protected]>
1 parent 90e1c7a commit ba3940a

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

guides/release/routing/specifying-a-routes-model.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,29 @@ export default class PostRoute extends Route {
184184
}
185185
```
186186

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';
188197

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+
}
192204
}
193205
```
194206

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.
200210

201211
### Linking to a dynamic segment
202212

@@ -299,7 +309,7 @@ import RSVP from 'rsvp';
299309

300310
export default class AlbumRoute extends Route {
301311
@service store;
302-
312+
303313
model({ album_id }) {
304314
return RSVP.hash({
305315
album: this.store.findRecord('album', album_id),

0 commit comments

Comments
 (0)