I'm trying to reproduce Railscasts 410 example (called Raffler
), changing the setup for last versions and to match my habits:
- Ember 1.0.0-rc.6
- Rails 4.0.0
- Mongoid master (4.0)
- Haml 4
- Emblem 0.3.0
In this example project, we create a simple model Entry
that calls a small Rails Rest API.
Everything works as expected, except that calling Raffler.Entry.find() to get all entries only loads the last record.
Here is my model :
Raffler.Entry = DS.Model.extend
name: DS.attr('string')
winner: DS.attr('boolean')
My store :
DS.RESTAdapter.configure('plurals', entry: 'entries')
Raffler.Store = DS.Store.extend
revision: 12
adapter: DS.RESTAdapter.create()
When calling Raffler.Entry.find()
there's an AJAX request on http://localhost:3000/entries
and all records are returned (so I don't think the problem is server side) :
{"entries":[{"id":{"$oid":"51e5b35b492cd4d286000001"},"name":"Foo","winner":true},{"id":{"$oid":"51e5b35b492cd4d286000002"},"name":"Bar","winner":false},{"id":{"$oid":"51e5b384492cd4d286000003"},"name":"Baz","winner":true}]}
But only the last of these records is really loaded in the model.
Here in the JS console :
e=Raffler.Entry.find()
e.toArray().length
=> 1
e.objectAt(0).get('name')
=> "Baz" (always the last one)
e.objectAt(1)
=> undefined