Reputation: 1728
I'm trying to update the Ember-Brunch (original repository: https://github.com/icholy/ember-brunch) to the latest EmberJS and EmberJS-Data frameworks. The current problem I have is I am trying to convert the original Bob model into a DS.Model
using a DS.FixtureAdapter
in the DS.Store
. But whatever I try I run into issues getting the data to display. Here are a couple attempts:
With the route:
App.BobRoute = Ember.Route.extend({
model: function() {
return App.Bob.find();
}
});
I get the following error:
Uncaught TypeError: Cannot call method 'hasOwnProperty' of null
And if I switch to this route:
App.BobRoute = Ember.Route.extend({
setupController: function() {
App.BobController.set('content', App.Bob.find());
}
});
I get the following errors:
Uncaught TypeError: Object App.BobController has no method 'set' app.js:184 Uncaught TypeError: Cannot call method 'hasOwnProperty' of null
Any ideas?
You can see my current work https://github.com/seankeating/ember-brunch and my attempt to do this in the DS.Model-Implementation-For-Using-Local-DSStore branch.
Store:
App.Store = DS.Store.extend({
revision: 11,
adapter: DS.FixtureAdapter.create()
});
Controller:
App.BobController = Em.ObjectController.extend({
});
Model:
var App = require('app'),
attr = DS.attr;
App.Bob = DS.Model.extend({
firstName : attr('string'),
lastName : attr('string'),
lyrics : attr('string'),
fullName: function(){
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName')
});
App.Bob.FIXTURES = [{
firstName: 'bob',
lastName: 'marley',
lyrics: 'no woman no cry!'
}];
Template:
<h2>{{fullName}}'s page!</h2>
<button class="btn btn-success" {{action doClick target="view"}}>click me</button>
{{#linkTo home}}<button class="btn" {{action doHome}}>go back home</button>{{/linkTo}}
Upvotes: 0
Views: 1140
Reputation: 28703
Before bc755f9, you needed to supply your fixture keys as Strings, which is how Ember Data stores them internally.
Now, you can use either numbers or strings as fixture IDs, and everything will work as expected.
Separately, you should always use the debug build of Ember.js in development, which provides much better error messages should something go wrong. As of ea6922f, the production build of Ember.js will warn you if you are running it in localhost
or 127.0.0.1
.
Upvotes: 2