-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Error while loading route: undefined " when setting route model hook #39
Comments
I am unsure if it is directly related, but I noticed. https://github.com/firebase/emberFire/blob/master/src/data.js#L181 doesn't enqueue an actual error object, which likely is resulting in a poor error message. This is due to crappy error logging in the router: https://github.com/emberjs/ember.js/blob/master/packages_es6/ember-routing/lib/system/router.js#L525 But in general it is best practice to reject with error objects |
@jrhe I went to https://emberfire-test.firebaseio.com/posts.json in the browser and it looks like your Firebase doesn't have any data at the @stefanpenner I'll update that so it throws an actual error. |
@aputinski Does that mean you have to bootstrap your firebase with some data? If not, how are you then supposed to handle empty collections? |
Luckily I haven't hit this problem yet because I'm accessing a non-existing child collection through a record that does exist in firebase and it works well. But I see a future use case where I will hit this problem. I went through the code to understand why it was working in my case and interestingly I noticed that if you access a non-existing collection (could be anything really) through a parent record like so Usually it's a good practice to return empty objects as opposed to You can handle the rejection like so,
|
simplification of @mbykovskyy example route.store.find('post').catch(function(reason) {
// check if reason tells us it was just "not found"
return [];
}); |
Nice one @stefanpenner! |
@stefanpenner would there be any harm in returning an empty array in the adapter if no data was found instead of rejecting? https://github.com/firebase/emberFire/blob/master/src/data.js#L257 |
@aputinski I am unsure |
I knew that I had no data but I couldn't figure out how to create it On 11 April 2014 17:54, Stefan Penner notifications@github.com wrote:
|
and ef349ea . Fixes issue FirebaseExtended#39
@aputinski Your fixes work well. |
will using {{link-to 'HOME' 'home'}} break an app? also is this discouraged? |
I followed the readme to get a basic setup, added a model and then implemented a model hook in a route to return all of the model. This throws the error:
Error while loading route: undefined
I have also tried creating records but they don't seem to get persisted but this may be a separate issue.
I have compiled a minimal jsbin of the problem:
http://emberjs.jsbin.com/kuyujohi/14/edit
The text was updated successfully, but these errors were encountered: