Last active
August 29, 2015 14:04
-
-
Save JemiloII/504161f01863aafe1cbf to your computer and use it in GitHub Desktop.
Just wanting to retrieve data the Ember way~
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.App = Ember.Application.create({ | |
LOG_TRANSITIONS: true | |
}); | |
App.Router.map(function(){ | |
this.resource('about'); | |
this.resource('users'); | |
}); | |
App.Router.reopen({ | |
rootURL: '/amber', | |
location: 'history' | |
}); | |
App.ApplicationAdapter = DS.RESTAdapter.create({ | |
url: 'http://localhost:1337' | |
}); | |
App.ApplicationStore = DS.Store.extend(); | |
App.User = DS.Model.extend({ | |
name: DS.attr('string'), | |
createdAt: DS.attr('date'), | |
updatedAt: DS.attr('date'), | |
}); | |
App.UsersRoute = Ember.Route.extend({ | |
model: function(){ | |
return this.store.find('user'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Testing Ember</title> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
<nav> | |
{{#link-to 'index'}}Home{{/link-to}} | | |
{{#link-to 'users'}}Users{{/link-to}} | | |
{{#link-to 'about'}}About{{/link-to}} | |
</nav> | |
<h1>Hello World!</h1> | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" id="index"> | |
<h2>Home</h2> | |
</script> | |
<script type="text/x-handlebars" id="users"> | |
<h2>Users</h2> | |
{{#if user}} | |
{{#each}} | |
<p>{{name}}</p> | |
{{/each}} | |
{{/if}} | |
</script> | |
<script type="text/x-handlebars" id="about"> | |
<h2>About</h2> | |
</script> | |
<script src="js/config/jquery-2.1.1.min.js"></script> | |
<script src="js/config/handlebars-1.3.0.js"></script> | |
<script src="js/config/ember.js"></script> | |
<script src="js/config/ember-data.js"></script> | |
<script src="js/app.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"user": [ | |
{ | |
"name": "brian", | |
"createdAt": "2014-07-15T06:20:31.504Z", | |
"updatedAt": "2014-07-15T06:21:02.474Z", | |
"id": 1 | |
}, | |
{ | |
"name": "sky", | |
"createdAt": "2014-07-15T06:20:26.045Z", | |
"updatedAt": "2014-07-15T06:21:20.377Z", | |
"id": 2 | |
}, | |
{ | |
"name": "lux", | |
"createdAt": "2014-07-15T06:21:39.812Z", | |
"updatedAt": "2014-07-15T06:21:39.812Z", | |
"id": 3 | |
}, | |
{ | |
"name": "garen", | |
"createdAt": "2014-07-15T06:21:59.959Z", | |
"updatedAt": "2014-07-15T06:21:59.959Z", | |
"id": 4, | |
}, | |
{ | |
"name": "teemo", | |
"createdAt": "2014-07-15T06:22:11.829Z", | |
"updatedAt": "2014-07-15T06:22:11.829Z", | |
"id": 5, | |
}, | |
{ | |
"name": "ahri", | |
"createdAt": "2014-07-15T06:22:21.768Z", | |
"updatedAt": "2014-07-15T06:23:15.108Z", | |
"id": 6 | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[✓] route:users ................................................ App.UsersRoute ember.js:3911 | |
Attempting transition to users ember.js:3911 | |
Transition #1: users: calling beforeModel hook ember.js:3911 | |
Transition #1: users: calling deserialize hook ember.js:3911 | |
[✓] model:user ................................................. App.User ember.js:3911 | |
[ ] adapter:user ............................................... App.UserAdapter ember.js:3911 | |
[✓] adapter:application ........................................ App.ApplicationAdapter ember.js:3911 | |
[ ] template:error ............................................. template at error ember.js:3911 | |
[ ] route:error ................................................ App.ErrorRoute ember.js:3911 | |
Error while processing route: users undefined is not a function TypeError: undefined is not a function | |
at instantiate (http://localhost/amber/js/config/ember.js:46604:26) | |
at lookup (http://localhost/amber/js/config/ember.js:46470:19) | |
at Object.Container.lookup (http://localhost/amber/js/config/ember.js:46145:16) | |
at Ember.Object.extend.adapterFor (http://localhost/amber/js/config/ember-data.js:11013:78) | |
at Ember.Object.extend.fetchAll (http://localhost/amber/js/config/ember-data.js:10264:28) | |
at Ember.Object.extend.findAll (http://localhost/amber/js/config/ember-data.js:10253:21) | |
at Ember.Object.extend.find (http://localhost/amber/js/config/ember-data.js:9918:23) | |
at App.UsersRoute.Ember.Route.extend.model (http://localhost/amber/js/app.js:32:21) | |
at apply (http://localhost/amber/js/config/ember.js:7993:27) | |
at superWrapper [as model] (http://localhost/amber/js/config/ember.js:7570:15) ember.js:3911 | |
Transition #1: users: transition was aborted ember.js:3911 | |
TypeError: undefined is not a function | |
at instantiate (http://localhost/amber/js/config/ember.js:46604:26) | |
at lookup (http://localhost/amber/js/config/ember.js:46470:19) | |
at Object.Container.lookup (http://localhost/amber/js/config/ember.js:46145:16) | |
at Ember.Object.extend.adapterFor (http://localhost/amber/js/config/ember-data.js:11013:78) | |
at Ember.Object.extend.fetchAll (http://localhost/amber/js/config/ember-data.js:10264:28) | |
at Ember.Object.extend.findAll (http://localhost/amber/js/config/ember-data.js:10253:21) | |
at Ember.Object.extend.find (http://localhost/amber/js/config/ember-data.js:9918:23) | |
at App.UsersRoute.Ember.Route.extend.model (http://localhost/amber/js/app.js:32:21) | |
at apply (http://localhost/amber/js/config/ember.js:7993:27) | |
at superWrapper [as model] (http://localhost/amber/js/config/ember.js:7570:15) ember.js:3911 | |
Uncaught Error: Assertion Failed: TypeError: undefined is not a function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you figure this out?