Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Resources should still generate ObjectControllers

  • Loading branch information...
commit a0f970a62867bb4752c1ae72be4501f92036178b 1 parent 55a340c
Tom Dale authored
View
3  lib/generators/ember/controller_generator.rb
@@ -7,11 +7,14 @@ class ControllerGenerator < ::Rails::Generators::NamedBase
desc "Creates a new Ember.js controller"
class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects"
+ class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object"
def create_controller_files
file_path = File.join('app/assets/javascripts/controllers', class_path, "#{file_name}_controller.js")
if options.array?
template 'array_controller.js', file_path
+ elsif options.object?
+ template 'object_controller.js', file_path
else
template 'controller.js', file_path
end
View
2  lib/generators/ember/resource_override.rb
@@ -14,7 +14,7 @@ def add_ember
say_status :invoke, "ember controller and view (singular)", :white
with_padding do
- invoke "ember:view"
+ invoke "ember:view", [singular_name], :object => true
end
@_invocations[Ember::Generators::ControllerGenerator].delete "create_controller_files"
View
1  lib/generators/ember/view_generator.rb
@@ -7,6 +7,7 @@ class ViewGenerator < ::Rails::Generators::NamedBase
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"
+ class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object"
def create_view_files
template 'view.js', File.join('app/assets/javascripts/views', class_path, "#{file_name}_view.js")
View
6 lib/generators/templates/array_controller.js
@@ -1,7 +1,3 @@
<%= application_name.camelize %>.<%= class_name %>Controller = Ember.ArrayController.extend({
- // Implement your controller here.
- //
- // An ArrayController has a `content` property, which you should
- // set up in your router.
-});
+});
View
3  lib/generators/templates/controller.js
@@ -1,4 +1,3 @@
<%= application_name.camelize %>.<%= class_name %>Controller = Ember.Controller.extend({
- // Implement your controller here.
-});
+});
View
3  lib/generators/templates/object_controller.js
@@ -0,0 +1,3 @@
+<%= application_name.camelize %>.<%= class_name %>Controller = Ember.ObjectController.extend({
+
+});
Please sign in to comment.
Something went wrong with that request. Please try again.