Permalink
Browse files

A bunch of cleanup and updates for latest

  • Loading branch information...
1 parent 9706e30 commit 83982d190c3510fbd77da1f3a2d790bb4287b4a7 @wycats wycats committed May 30, 2012
@@ -43,9 +43,13 @@ def create_app_file
def create_router_file
template "router.js", "#{ember_path}/routes/app_router.js"
end
-
- def create_app_template
- template "application.handlebars", "#{ember_path}/templates/application.handlebars"
+
+ def create_store_file
+ template "store.js", "#{ember_path}/store.js"
+ end
+
+ def create_app_stubs
+ generate "ember:view", "application"
end
def inject_proper_ember_version
@@ -4,15 +4,17 @@ module Ember
module Generators
class ViewGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("../../templates", __FILE__)
- argument :controller_name, :type => :string, :required => true, :desc => "The controller name for this view"
-
+
desc "Creates a new Ember.js view and associated Handlebars template"
-
+ class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects"
+
def create_model_files
- template 'view.js', File.join('app/assets/javascripts/views/' + controller_name, class_path, "#{file_name}_view.js")
- template 'view.handlebars', File.join('app/assets/javascripts/templates/' + controller_name, class_path, "#{file_name}.handlebars")
+ template 'view.js', File.join('app/assets/javascripts/views', class_path, "#{file_name}_view.js")
+ template 'view.handlebars', File.join('app/assets/javascripts/templates', class_path, "#{file_name}.handlebars")
+ generate 'ember:controller', file_name, "--array" if options[:array]
+ generate 'ember:controller', file_name unless options[:array]
end
-
+
end
end
end
@@ -1,15 +1,20 @@
+//= require ./store
//= require_tree ./models
//= require_tree ./controllers
//= require_tree ./views
//= require_tree ./helpers
//= require_tree ./templates
-//= require_tree ./states
+//= require_tree ./routes
//= require_self
-var router = <%= application_name.camelize %>.router = <%= application_name.camelize %>.Router.create();
-<%= application_name.camelize %>.initialize(router);
+var router = <%= application_name.camelize %>.router = <%= application_name.camelize %>.Router.create({
+ location: 'hash'
+});
-jQuery(function() {
- router.send('ready');
+<%= application_name.camelize %>.Store = DS.Store.extend({
+ revision: 4,
+ adapter: DS.RESTAdapter.create()
});
+<%= application_name.camelize %>.initialize(router);
+
@@ -1,15 +1,14 @@
<%= application_name.camelize %>.Router = Ember.Router.extend({
root: Ember.State.extend({
- index: Ember.State.extend({
- route: '/'
-
+ index: Ember.State.extend({
+ route: '/'
+
// You'll likely want to connect a view here.
// connectOutlets: function(router) {
// router.get('applicationController').connectOutlet(App.MainView);
// }
-
- // Layout your routes here...
-
+
+ // Layout your routes here...
})
})
});
@@ -0,0 +1,5 @@
+<%= application_name.camelize %>.Store = DS.Store.extend({
+ revision: 4,
+ adapter: DS.RESTAdapter.create()
+});
+
@@ -1,3 +1,5 @@
<h1><%= class_name %></h1>
-<p>Your content here.</p>
+<p>Your content here.</p>
+
+{{outlet}}
@@ -1,4 +1,3 @@
<%= application_name.camelize %>.<%= class_name.camelize %>View = Ember.View.extend({
- templateName: '<%= controller_name.camelize(:lower) %>/<%= class_name.underscore %>',
- controller: <%= application_name.camelize %>.<%= controller_name.camelize(:lower) %>Controller
-});
+ templateName: '<%= class_name.underscore %>'
+});
@@ -1073,7 +1073,7 @@ DS.Store = Ember.Object.extend({
// create a new instance of the model type in the
// 'isLoading' state
- record = this.materializeRecord(type, clientId);
+ record = this.materializeRecord(type, clientId, id);
// let the adapter set the data, possibly async
var adapter = get(this, '_adapter');
@@ -1578,12 +1578,13 @@ DS.Store = Ember.Object.extend({
// . RECORD MATERIALIZATION .
// ..........................
- materializeRecord: function(type, clientId) {
+ materializeRecord: function(type, clientId, id) {
var record;
get(this, 'recordCache')[clientId] = record = type._create({
store: this,
- clientId: clientId
+ clientId: clientId,
+ _id: id
});
get(this, 'defaultTransaction').adoptRecord(record);
@@ -2642,7 +2643,8 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
return value;
}
- return data && get(data, primaryKey);
+ var id = get(data, primaryKey);
+ return id ? id : this._id;
}).property('primaryKey', 'data'),
// The following methods are callbacks invoked by `toJSON`. You
Oops, something went wrong.

0 comments on commit 83982d1

Please sign in to comment.