ember-learn / ember-learn/guides-source

Correction needed for Defining a Route's Model - default model hook behavior

Open
#782 0 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
HTML
Stars
161
Forks
512
Avg merge
4d 9h
Merged PRs (30d)
4

Description

This is the section that isn't quite right, identified by runspired:

```
If you do not define a model hook for a route, it will default to using Ember Data to look up the record, as shown below:

model(params) {
return this.store.find('post', params.post_id);
}
```

A more accurate statement is:

> If you do not define a model hook for a route, it will default to using Ember's DefaultStore interface to look up the record, as shown below:

So any data-related plugin has to address this behavior. It's not unique to Ember Data.

To-do:
- [ ] figure out how to explain this in a way that doesn't require us to also explain the undocumented DefaultStore, and makes it clear that any data plugin will result in some behavior like this
- [ ] replace the incorrect explanation currently published in the Guides
- [ ] Make the PR to the `master` branch of this repository

Background info, which should not go in the Guides:

The DefaultStore is undocumented, but lives here: https://github.com/emberjs/ember.js/blob/52ddee883414f655511ef71d6f875f3fc16028e3/packages/%40ember/-internals/routing/lib/system/route.ts#L2145-L2176

the best mention in the docs is this one: https://api.emberjs.com/ember/3.9/classes/Route/properties/store?anchor=routeName&show=inherited%2Cprivate

what actually happens is that libraries like ember-model and ember-data "Do A Bad Thing"™ because of this DefaultStore. It forces us to eagerly inject store onto all routes to replace this store property and it forces us Ember Data to support store.find.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.