Skip to content

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

Open
@jenweber

Description

@jenweber

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions