Skip to content

Instantly share code, notes, and snippets.

@blackjk3
Created August 7, 2013 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackjk3/6177127 to your computer and use it in GitHub Desktop.
Save blackjk3/6177127 to your computer and use it in GitHub Desktop.
Ember Starter with rest.
App = Ember.Application.create({
rootElement: '.affix-container',
ready: function() {
console.log('ember ready');
App.requestController = App.RequestController.create();
}
});
DS.RESTAdapter.reopen({
namespace: 'portal/requests/api'
});
DS.RESTAdapter.registerTransform('object', {
deserialize: function(serialized) {
return Em.isNone(serialized) ? {} : serialized;
},
serialize: function(deserialized) {
return Em.isNone(deserialized) ? {} : deserialized;
}
});
App.Store = DS.Store.extend({
adapter: DS.RESTAdapter
});
App.Request = DS.Model.extend({
active: DS.attr('boolean'),
created_on: DS.attr('date'),
modified_on: DS.attr('date'),
project: DS.attr('object')
});
App.RequestController = Ember.ObjectController.extend({
init: function() {
console.log('init controller');
},
fetch: function(id) {
this.set('model', App.Request.find(id) );
}
});
$(function() {
console.log('dom ready');
App.requestController.fetch(10621);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment