From 33504de1cd3dc1e1f87c581a8154870f1fcf0796 Mon Sep 17 00:00:00 2001 From: Peter Wagenet Date: Tue, 7 Mar 2023 08:52:23 -0800 Subject: [PATCH] Remove documentation for implicit route model --- .../routing/specifying-a-routes-model.md | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/guides/release/routing/specifying-a-routes-model.md b/guides/release/routing/specifying-a-routes-model.md index 78f2875934..0aa2b38a7c 100644 --- a/guides/release/routing/specifying-a-routes-model.md +++ b/guides/release/routing/specifying-a-routes-model.md @@ -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 [``](../../templates/links/). @@ -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),