[Bug] When not providing a route model
hook, and not providing a model with a .find
function, an error occurs
#19972
Labels
model
hook, and not providing a model with a .find
function, an error occurs
#19972
🐞 Describe the Bug
If I have a route for which I do not implement the
model
hook, Ember tries to be clever and make a request for the inferred model for the route. In order to do this it looks up amodel:${name}
factory and if it finds one, it calls the.find
function on it. However, if the model factory does not have afind
method we get an error.The code has have dev assertions for the
.find
method, however, in prod these are stripped out resulting in a hard error.The code in question is here:
ember.js/packages/@ember/-internals/routing/lib/system/route.ts
Line 1863 in 8455848
🔬 Minimal Reproduction
https://stackblitz.com/edit/github-xrliqn
model
hook/pets/1
😕 Actual Behavior
The following error is thrown
🤔 Expected Behavior
Nothing should happen. There should be no error. And there should be no assertion in dev.
🌍 Environment
➕ Additional Context
This bug came about out of a discussion around emberjs/rfcs#774
The text was updated successfully, but these errors were encountered: