0

I recreated the TodoMVC using EmberJS and after I was finished, I tried to change the ApplicationAdapter to FirebaseAdapter. But then the application stopped working and I am getting this error:

Error while loading route: undefined 

Here are the version I am using

Ember      : 1.5.0
Ember Data : 1.0.0-beta.7+canary.b45e23ba
Handlebars : 1.3.0
jQuery     : 2.1.0

You can check out the code at github but here are some of the file contents.

With this code, it works

Todos.ApplicationAdapter = DS.FixtureAdapter.extend();

But when I change it to this, it stops working and I get the error:

Todos.ApplicationAdapter = DS.FirebaseAdapter.extend({
    firebase: new Firebase('https://glaring-fire-8506.firebaseio.com')
});

I have the TodosController and TodoController, and this is my router file

Todos.Router.map(function () {
    this.resource('todos', { path: '/' }, function () {
        this.route('active');
        this.route('completed');
    });
});

Todos.TodosRoute = Ember.Route.extend({
    model: function () {
        return this.store.find('todo');
    }
});

Todos.TodosIndexRoute = Ember.Route.extend({
    model: function () {
        return this.modelFor('todos');
    },

    renderTemplate: function (controller) {
        this.render('todos/index', {
            controller: controller
        });
    }
});

Todos.TodosActiveRoute = Todos.TodosIndexRoute.extend({
    model: function () {
        return this.store.filter('todo', function (todo) {
            return !todo.get('isCompleted');
        });
    }
});

Todos.TodosCompletedRoute = Todos.TodosIndexRoute.extend({
    model: function () {
        return this.store.filter('todo', function (todo) {
            return todo.get('isCompleted');
        });
    }
});

EDIT: when I added the todos JSON object to Firebase, it's working as it should. But I would really want to understand the problem.

Mirko Akov
  • 2,357
  • 19
  • 19
  • Hi Mirko, can you post a small sample of code that reproduces the error? It's good etiquette and shows proper due diligence to narrow it down to a small sample, rather than asking others to clone/build/learn/troubleshoot your app, which could change as you commit fixes and then not even be capable of reproducing the error anymore. – Kato Apr 04 '14 at 01:18
  • @Kato I also have this problem. Here is a minimal jsbin. http://emberjs.jsbin.com/kuyujohi/14/edit?js – Jonathan Evans Apr 10 '14 at 06:56
  • Created a separate question to make it more obvious. – Jonathan Evans Apr 10 '14 at 07:10

1 Answers1

0

The problem was with the emberFire not handing empty / non-existent collections. This has now been fixed in the emberFire repo.

Github issue: https://github.com/firebase/emberFire/issues/39

Jonathan Evans
  • 974
  • 2
  • 8
  • 18