ember-appkit-rails 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/Rakefile +31 -6
  4. data/app/assets/javascripts/templates/application.hbs +7 -0
  5. data/app/controllers/landing_controller.rb +5 -0
  6. data/lib/ember-appkit-rails.rb +9 -0
  7. data/lib/ember/appkit.rb +5 -0
  8. data/lib/ember/appkit/rails.rb +4 -4
  9. data/lib/ember/appkit/rails/engine.rb +37 -9
  10. data/lib/ember/appkit/rails/resource_override.rb +14 -0
  11. data/lib/ember/appkit/rails/sprockets.rb +4 -0
  12. data/lib/ember/appkit/rails/sprockets/directive_processor.rb +9 -0
  13. data/lib/ember/appkit/rails/sprockets/processed_asset.rb +27 -0
  14. data/lib/ember/appkit/rails/version.rb +1 -1
  15. data/lib/generators/ember/bootstrap_generator.rb +58 -19
  16. data/lib/generators/ember/component_generator.rb +2 -4
  17. data/lib/generators/ember/controller_generator.rb +1 -3
  18. data/lib/generators/ember/generator_helpers.rb +18 -10
  19. data/lib/generators/ember/helper_generator.rb +17 -0
  20. data/lib/generators/ember/model_generator.rb +3 -4
  21. data/lib/generators/ember/resource_generator.rb +13 -1
  22. data/lib/generators/ember/route_generator.rb +1 -2
  23. data/lib/generators/ember/scaffold_generator.rb +52 -0
  24. data/lib/generators/ember/template_generator.rb +1 -2
  25. data/lib/generators/ember/view_generator.rb +1 -4
  26. data/lib/generators/templates/adapter.js +3 -0
  27. data/lib/generators/templates/application.js.erb +11 -0
  28. data/lib/generators/templates/array_controller.js.es6 +1 -3
  29. data/lib/generators/templates/component.js.es6 +1 -1
  30. data/lib/generators/templates/controller.js.es6 +1 -2
  31. data/{test/dummy/app/utils → lib/generators/templates}/csrf.js +0 -0
  32. data/lib/generators/templates/environment.js +12 -0
  33. data/{test/dummy/app/views/application/show.html → lib/generators/templates/environments/development.js} +0 -0
  34. data/lib/generators/templates/environments/production.js +0 -0
  35. data/lib/generators/templates/environments/test.js +0 -0
  36. data/lib/generators/templates/helper.js +2 -0
  37. data/lib/generators/templates/model.js.es6 +1 -1
  38. data/lib/generators/templates/object_controller.js.es6 +1 -3
  39. data/lib/generators/templates/route.js.es6 +1 -2
  40. data/lib/generators/templates/router.js.es6 +1 -2
  41. data/lib/generators/templates/scaffold/route/edit.js.es6 +22 -0
  42. data/lib/generators/templates/scaffold/route/index.js.es6 +5 -0
  43. data/lib/generators/templates/scaffold/route/new.js.es6 +23 -0
  44. data/lib/generators/templates/scaffold/route/show.js.es6 +14 -0
  45. data/lib/generators/templates/scaffold/template.hbs +3 -0
  46. data/lib/generators/templates/scaffold/template/edit.hbs +3 -0
  47. data/lib/generators/templates/scaffold/template/form.hbs +9 -0
  48. data/lib/generators/templates/scaffold/template/index.hbs +20 -0
  49. data/lib/generators/templates/scaffold/template/new.hbs +3 -0
  50. data/lib/generators/templates/scaffold/template/show.hbs +9 -0
  51. data/lib/generators/templates/template.hbs +0 -5
  52. data/lib/generators/templates/view.js.es6 +1 -2
  53. data/test/dummy/Gemfile +40 -0
  54. data/test/dummy/config/adapter.js +3 -0
  55. data/test/dummy/config/application.js +11 -0
  56. data/test/dummy/config/application.rb +24 -8
  57. data/test/dummy/config/boot.rb +1 -2
  58. data/test/dummy/config/environment.js +12 -0
  59. data/test/dummy/config/environments/development.js +0 -0
  60. data/test/dummy/config/environments/development.rb +1 -3
  61. data/test/dummy/config/environments/production.js +0 -0
  62. data/test/dummy/config/environments/test.js +0 -0
  63. data/test/dummy/config/environments/test.rb +1 -1
  64. data/test/dummy/config/initializers/csrf.js +9 -0
  65. data/test/dummy/config/initializers/secret_token.rb +1 -1
  66. data/test/dummy/config/initializers/wrap_parameters.rb +0 -5
  67. data/test/dummy/{app/assets/javascripts → config}/router.js.es6 +1 -2
  68. data/test/dummy/config/routes.rb +55 -2
  69. data/test/dummy/log/test.log +14 -175
  70. data/test/dummy/public/robots.txt +5 -0
  71. data/test/dummy/tmp/Gemfile +45 -0
  72. data/test/dummy/{app → tmp/app}/assets/javascripts/application.js +3 -1
  73. data/test/dummy/tmp/app/assets/javascripts/custom/application.js +16 -0
  74. data/test/dummy/tmp/app/templates/post.hbs +0 -0
  75. data/test/dummy/tmp/app/views/layouts/application.html.erb +14 -0
  76. data/test/dummy/tmp/cache/assets/test/sprockets/07afa5d8ceda557642e2330ab45eb203 +0 -0
  77. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  78. data/test/dummy/tmp/cache/assets/test/sprockets/1f15c49a05b13c3a7ee50d2ac3900f38 +0 -0
  79. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  80. data/test/dummy/tmp/cache/assets/test/sprockets/4a1d4e32cd7b9fd1c62bfd553ae56051 +0 -0
  81. data/test/dummy/tmp/cache/assets/test/sprockets/660bc633c8899c6c1b20514637fa0169 +0 -0
  82. data/test/dummy/tmp/cache/assets/test/sprockets/67afcba9807cd5e57b80b5fdf9f26758 +0 -0
  83. data/test/dummy/tmp/cache/assets/test/sprockets/6870da13c3305651063dc22ccce27d5c +0 -0
  84. data/test/dummy/tmp/cache/assets/test/sprockets/7ca4966e0a480430a858a7ab74518c75 +0 -0
  85. data/test/dummy/tmp/cache/assets/test/sprockets/827fafc13575b345cc572fd041ef1fba +0 -0
  86. data/test/dummy/tmp/cache/assets/test/sprockets/83af35bb6b852de883a26a9458fd4e3a +0 -0
  87. data/test/dummy/tmp/cache/assets/test/sprockets/8ebc8c58233ab12eee6edfc0feca2492 +0 -0
  88. data/test/dummy/tmp/cache/assets/test/sprockets/9160f792acb62d1f7721c714681fcfe6 +0 -0
  89. data/test/dummy/tmp/cache/assets/test/sprockets/a2f615309ade94c14ae81d7ebc94fd67 +0 -0
  90. data/test/dummy/tmp/cache/assets/test/sprockets/a9648a765fed0738b076bd24099109a3 +0 -0
  91. data/test/dummy/tmp/cache/assets/test/sprockets/ae884a1acda0e6f9bb27a856a22bb08d +0 -0
  92. data/test/dummy/tmp/cache/assets/test/sprockets/bb4a2293175928af3e23c47488077098 +0 -0
  93. data/test/dummy/tmp/cache/assets/test/sprockets/bf689240392e7355c0de5cfd47272146 +0 -0
  94. data/test/dummy/tmp/cache/assets/test/sprockets/c8c4c1b316845f30168739b5795846d6 +0 -0
  95. data/test/dummy/tmp/cache/assets/test/sprockets/{2f5173deea6c795b8fdde723bb4b63af → d5a48c6656341c56cac8a8e42bb925a5} +0 -0
  96. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  97. data/test/dummy/tmp/cache/assets/test/sprockets/{cffd775d018f68ce5dba1ee0d951a994 → de0932670a6c856bc6eda1586fd29061} +0 -0
  98. data/test/dummy/tmp/cache/assets/test/sprockets/de94a60b438eb5bf57653f3a220acd80 +0 -0
  99. data/test/dummy/tmp/cache/assets/test/sprockets/e22019b3c13c20bc08e899fb2b7248ea +0 -0
  100. data/test/dummy/tmp/cache/assets/test/sprockets/e9abb671d48f6ff2be6ffb463ea652bf +0 -0
  101. data/test/dummy/tmp/cache/assets/test/sprockets/eeb5bd38d1dad0d908461fd114f702bc +0 -0
  102. data/test/dummy/tmp/cache/assets/test/sprockets/fde9e78f8d55a70f4ef757638fc6cde0 +0 -0
  103. data/test/dummy/tmp/cache/assets/test/sprockets/fdfac6623944c5a23737724cbd90e58e +0 -0
  104. data/test/dummy/tmp/ember-rails/ember-data.js +3787 -5850
  105. data/test/dummy/tmp/generator_test_output/Gemfile +45 -0
  106. data/test/dummy/tmp/generator_test_output/app/assets/javascripts/application.js +16 -0
  107. data/test/dummy/tmp/generator_test_output/app/assets/javascripts/custom/application.js +16 -0
  108. data/test/dummy/tmp/generator_test_output/app/views/layouts/application.html.erb +14 -0
  109. data/test/dummy/tmp/generator_test_output/app/views/post.js.es6 +2 -0
  110. data/test/fixtures/rails_4-0-0_Gemfile +45 -0
  111. data/test/fixtures/rails_4-0-0_application.js +16 -0
  112. data/test/fixtures/rails_4-0-0_application_layout +14 -0
  113. data/test/generators/bootstrap_generator_test.rb +72 -17
  114. data/test/generators/component_generator_test.rb +13 -20
  115. data/test/generators/controller_generator_test.rb +7 -18
  116. data/test/generators/helper_generator_test.rb +16 -0
  117. data/test/generators/model_generator_test.rb +7 -14
  118. data/test/generators/resource_generator_test.rb +12 -11
  119. data/test/generators/resource_override_test.rb +29 -0
  120. data/test/generators/route_generator_test.rb +1 -9
  121. data/test/generators/scaffold_generator_test.rb +48 -0
  122. data/test/generators/template_generator_test.rb +4 -10
  123. data/test/generators/view_generator_test.rb +11 -18
  124. data/test/integration/navigation_test.rb +11 -3
  125. data/test/support/generator_test_support.rb +59 -18
  126. data/test/support/integration_test_support.rb +12 -0
  127. data/vendor/assets/javascripts/app.js.es6.erb +27 -0
  128. data/vendor/assets/javascripts/ember-appkit/index.js +1 -0
  129. data/vendor/assets/javascripts/ember-appkit/resolver.js +13 -9
  130. metadata +133 -90
  131. data/lib/generators/templates/application.js +0 -2
  132. data/lib/generators/templates/ember-app.js.es6 +0 -15
  133. data/test/dummy/app/assets/javascripts/components/my-component.js.es6 +0 -4
  134. data/test/dummy/app/assets/javascripts/controllers/index.js.es6 +0 -7
  135. data/test/dummy/app/assets/javascripts/ember-app.js +0 -9
  136. data/test/dummy/app/assets/javascripts/models/person.js.es6 +0 -3
  137. data/test/dummy/app/assets/javascripts/routes/index.js.es6 +0 -13
  138. data/test/dummy/app/assets/javascripts/templates/application.hbs +0 -2
  139. data/test/dummy/app/assets/javascripts/templates/components/my-component.hbs +0 -1
  140. data/test/dummy/app/assets/javascripts/templates/index.hbs +0 -6
  141. data/test/dummy/tmp/app/assets/javascripts/templates/post.hbs +0 -5
  142. data/test/dummy/tmp/cache/assets/test/sprockets/19c9bc7dbf67a891e93c7a663a62ff1c +0 -0
  143. data/test/dummy/tmp/cache/assets/test/sprockets/22d5df6f378a04858f2123ee6e176ff1 +0 -0
  144. data/test/dummy/tmp/cache/assets/test/sprockets/30e6b42a491dc4952ff020137405d502 +0 -0
  145. data/test/dummy/tmp/cache/assets/test/sprockets/331122f2f78d79778408023cf5bad1e3 +0 -0
  146. data/test/dummy/tmp/cache/assets/test/sprockets/34b3026e7f937c6a19a0aee7f8451aad +0 -0
  147. data/test/dummy/tmp/cache/assets/test/sprockets/36b770b8db4bb47ce9c524d7104be2e9 +0 -0
  148. data/test/dummy/tmp/cache/assets/test/sprockets/4bde569e155e5abfc2bc79bb61721688 +0 -0
  149. data/test/dummy/tmp/cache/assets/test/sprockets/720ee922899be7948cc2a8b27660ce0b +0 -0
  150. data/test/dummy/tmp/cache/assets/test/sprockets/7689ffe6d7c831ee178e07106482b2cc +0 -0
  151. data/test/dummy/tmp/cache/assets/test/sprockets/7bf1770d3a1c8bc1b59a4bc89d5c4bca +0 -0
  152. data/test/dummy/tmp/cache/assets/test/sprockets/7d008b32a16b10ea72ea849f47d9a095 +0 -0
  153. data/test/dummy/tmp/cache/assets/test/sprockets/8e9feb35d7e388f760d17aaf89b32731 +0 -0
  154. data/test/dummy/tmp/cache/assets/test/sprockets/b3a5b51571520b61f892c51e979b9f53 +0 -0
  155. data/test/dummy/tmp/cache/assets/test/sprockets/c0bb6b15bdd48873e96974816e18abe9 +0 -0
  156. data/test/dummy/tmp/cache/assets/test/sprockets/e2a67ad17895f7711966ca1a5ff7af86 +0 -0
  157. data/test/dummy/tmp/cache/assets/test/sprockets/e44f5ebcd8f42995512e64b96b63c9cf +0 -0
  158. data/test/dummy/tmp/cache/assets/test/sprockets/e8aa57b28c86586b8b7344feb891c43f +0 -0
  159. data/test/dummy/tmp/cache/assets/test/sprockets/ed5238112abbfd6a794a100804365903 +0 -0
  160. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  161. data/test/dummy/tmp/generator_test_output/app/assets/javascripts/views/post.js.es6 +0 -3
  162. data/vendor/assets/javascripts/app.js.es6 +0 -13
@@ -9,14 +9,13 @@ module Ember
9
9
  desc "Creates a new ember.js model"
10
10
  argument :attributes, :type => :array, :default => [], :banner => "field[:type] field[:type] ..."
11
11
 
12
- class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
13
-
14
12
  def create_model_files
15
- file_path = File.join(ember_path, 'models', class_path, "#{file_name}.js.es6")
13
+ file_path = File.join(app_path, 'models', class_path, "#{file_name}.js.es6")
16
14
  template "model.js.es6", file_path
17
15
  end
18
16
 
19
- private
17
+ private
18
+
20
19
  EMBER_TYPE_LOOKUP = {
21
20
  nil => 'string',
22
21
  :binary => 'string',
@@ -1,3 +1,4 @@
1
+ require 'ember/appkit/rails/resource_override'
1
2
  require 'generators/ember/generator_helpers'
2
3
 
3
4
  module Ember
@@ -14,11 +15,22 @@ module Ember
14
15
  class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object"
15
16
 
16
17
  def create_resource_files
17
- invoke('ember:route', [ name ], options) unless options[:skip_route]
18
+ unless options[:skip_route]
19
+ invoke('ember:route', [ name ], options)
20
+ inject_into_router_file(name)
21
+ end
18
22
  invoke('ember:controller', [ name ], options)
19
23
  invoke('ember:template', [ name ], options)
20
24
  end
21
25
 
26
+ private
27
+
28
+ def inject_into_router_file(name)
29
+ router_file = "#{config_path}/router.js.es6"
30
+ inject_into_file(router_file, :after => /^.*Router.map\(function\(\) \{*$/) do
31
+ "\n this.resource('#{name.pluralize}');"
32
+ end
33
+ end
22
34
  end
23
35
  end
24
36
  end
@@ -8,10 +8,9 @@ module Ember
8
8
  source_root File.expand_path("../../templates", __FILE__)
9
9
 
10
10
  desc "Creates a new Ember.js route"
11
- class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
12
11
 
13
12
  def create_route_files
14
- file_path = File.join(ember_path, 'routes', class_path, "#{file_name}.js.es6")
13
+ file_path = File.join(app_path, 'routes', class_path, "#{file_name}.js.es6")
15
14
  template "route.js.es6", file_path
16
15
  end
17
16
  end
@@ -0,0 +1,52 @@
1
+ require 'generators/ember/model_generator'
2
+
3
+ module Ember
4
+ module Generators
5
+ class ScaffoldGenerator < ModelGenerator
6
+ source_root File.expand_path("../../templates", __FILE__)
7
+ desc "Scaffolds a new Ember CRUD"
8
+
9
+ class_option :skip_route, :type => :boolean, :default => false, :desc => "Don't create route"
10
+ class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects"
11
+ class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object"
12
+
13
+ def create_route_files
14
+ create_resource_files_for(:route, 'js.es6')
15
+ inject_into_router_file(file_name)
16
+ end
17
+
18
+ def create_template_files
19
+ create_resource_files_for(:template, 'hbs')
20
+ template "scaffold/template.hbs", File.join(app_path, 'templates', "#{file_name.pluralize}.hbs")
21
+ template "scaffold/template/form.hbs", File.join(app_path, 'templates', file_name.pluralize, 'form.hbs')
22
+ end
23
+
24
+ private
25
+
26
+ def create_resource_files_for(type, extension)
27
+ dir = type.to_s.pluralize
28
+ resource = file_name.pluralize
29
+
30
+ [:edit, :index, :new, :show].each do |action|
31
+ template "scaffold/#{type}/#{action}.#{extension}", File.join(app_path, dir, "#{resource}/#{action}.#{extension}")
32
+ end
33
+ end
34
+
35
+ def inject_into_router_file(name)
36
+ router_file = "#{config_path}/router.js.es6"
37
+ js = <<-JS
38
+
39
+ this.resource('#{name.pluralize}', function() {
40
+ this.route('new');
41
+ this.route('show', {path: ':#{file_name.singularize}_id'});
42
+ this.route('edit', {path: ':#{file_name.singularize}_id/edit'});
43
+ });
44
+ JS
45
+ inject_into_file(router_file, :after => /^.*Router.map\(function\(\) \{*$/) do
46
+ js.rstrip
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
@@ -8,10 +8,9 @@ module Ember
8
8
  source_root File.expand_path("../../templates", __FILE__)
9
9
 
10
10
  desc "Creates a new Ember.js template."
11
- class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
12
11
 
13
12
  def create_template_files
14
- file_path = File.join(ember_path, 'templates', class_path, "#{file_name}.hbs")
13
+ file_path = File.join(app_path, 'templates', class_path, "#{file_name}.hbs")
15
14
  template 'template.hbs', file_path
16
15
  end
17
16
  end
@@ -8,16 +8,13 @@ module Ember
8
8
  source_root File.expand_path("../../templates", __FILE__)
9
9
 
10
10
  desc "Creates a new Ember.js view and associated template."
11
- class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
12
11
  class_option :without_template, :type => :boolean, :default => false, :desc => "Create template for this view"
13
12
 
14
13
  def create_view_files
15
- file_path = File.join(ember_path, 'views', class_path, "#{file_name}.js.es6")
14
+ file_path = File.join(app_path, 'views', class_path, "#{file_name}.js.es6")
16
15
  template "view.js.es6", file_path
17
16
  invoke('ember:template', [ name ], options) unless options[:without_template]
18
17
  end
19
18
  end
20
19
  end
21
20
  end
22
-
23
-
@@ -0,0 +1,3 @@
1
+ window.<%= application_name.camelize %>.ApplicationAdapter = DS.ActiveModelAdapter.extend({
2
+ namespace: 'api/v1'
3
+ });
@@ -0,0 +1,11 @@
1
+ //= require jquery
2
+ //= require environment
3
+ //= require ember-appkit
4
+ //= require ember-data
5
+ //= require_self
6
+ //= require adapter
7
+ //= require router
8
+ //= require_tree ../<%= app_path %>
9
+ //= require_tree ./initializers
10
+
11
+ window.<%= application_name.camelize %> = require('app').default.create();
@@ -1,4 +1,2 @@
1
- export default = <%= class_name.camelize %>Controller = Ember.ArrayController.extend({
2
-
1
+ export default Ember.ArrayController.extend({
3
2
  });
4
-
@@ -1,2 +1,2 @@
1
- export default = Ember.Component.extend({
1
+ export default Ember.Component.extend({
2
2
  });
@@ -1,3 +1,2 @@
1
- export default = <%= class_name.camelize %>Controller = Ember.Controller.extend({
2
-
1
+ export default Ember.Controller.extend({
3
2
  });
@@ -0,0 +1,12 @@
1
+ //= require_self
2
+ //= require_environment_from ./environments
3
+ /*
4
+ This is useful when using canary versions of Ember to enable
5
+ feature flags before Ember itself is loaded.
6
+
7
+ See the feature flags guide for details:
8
+
9
+ http://emberjs.com/guides/configuring-ember/feature-flags/
10
+ */
11
+
12
+ window.ENV = {};
File without changes
@@ -0,0 +1,2 @@
1
+ Ember.Handlebars.helper('<%= name %>', function(value) {
2
+ });
@@ -1,4 +1,4 @@
1
- export default = DS.Model.extend({
1
+ export default DS.Model.extend({
2
2
  <% attributes.each_with_index do |attribute, idx| -%>
3
3
  <%= attribute[:name].camelize(:lower) %>: <%=
4
4
  if %w(references belongs_to).member?(attribute[:type])
@@ -1,4 +1,2 @@
1
- export default = <%= class_name.camelize %>Controller = Ember.ObjectController.extend({
2
-
1
+ export default Ember.ObjectController.extend({
3
2
  });
4
-
@@ -1,3 +1,2 @@
1
- export default = <%= class_name.camelize %>Route = Ember.Route.extend({
2
-
1
+ export default Ember.Route.extend({
3
2
  });
@@ -1,7 +1,6 @@
1
1
  var Router = Ember.Router.extend();
2
2
 
3
3
  Router.map(function() {
4
-
5
4
  });
6
5
 
7
- export default = Router;
6
+ export default Router;
@@ -0,0 +1,22 @@
1
+ export default Ember.Route.extend({
2
+ model: function(params) {
3
+ return this.store.find('<%= file_name.singularize -%>', params.<%= file_name.singularize -%>_id);
4
+ },
5
+ deactivate: function() {
6
+ var model = this.get('controller.model');
7
+ model.rollback();
8
+ },
9
+ actions: {
10
+ save: function() {
11
+ var model = this.get('controller.model');
12
+ var _this = this;
13
+ model.save().then(function() {
14
+ _this.transitionTo('<%= file_name.pluralize -%>.show', model);
15
+ });
16
+ },
17
+ cancel: function() {
18
+ var model = this.get('controller.model');
19
+ this.transitionTo('<%= file_name.pluralize -%>.show', model);
20
+ }
21
+ }
22
+ });
@@ -0,0 +1,5 @@
1
+ export default Ember.Route.extend({
2
+ model: function() {
3
+ return this.store.find('<%= file_name.singularize -%>');
4
+ }
5
+ });
@@ -0,0 +1,23 @@
1
+ export default Ember.Route.extend({
2
+ model: function() {
3
+ return this.store.createRecord('<%= file_name.singularize -%>');
4
+ },
5
+ deactivate: function() {
6
+ var model = this.get('controller.model');
7
+ if (model.get('isNew')) {
8
+ model.deleteRecord();
9
+ }
10
+ },
11
+ actions: {
12
+ save: function() {
13
+ var model = this.get('controller.model');
14
+ var _this = this;
15
+ model.save().then(function() {
16
+ _this.transitionTo('<%= file_name.pluralize -%>.show', model);
17
+ });
18
+ },
19
+ cancel: function() {
20
+ this.transitionTo('<%= file_name.pluralize -%>.index');
21
+ }
22
+ }
23
+ });
@@ -0,0 +1,14 @@
1
+ export default Ember.Route.extend({
2
+ model: function(params) {
3
+ return this.store.find('<%= file_name.singularize -%>', params.<%= file_name.singularize -%>_id);
4
+ },
5
+ actions: {
6
+ destroyRecord: function() {
7
+ var model = this.get('controller.model');
8
+ var _this = this;
9
+ model.destroyRecord().then(function() {
10
+ _this.transitionTo('<%= file_name.pluralize -%>.index');
11
+ });
12
+ }
13
+ }
14
+ });
@@ -0,0 +1,3 @@
1
+ <h2><%= file_name.pluralize.titleize -%></h2>
2
+
3
+ {{outlet}}
@@ -0,0 +1,3 @@
1
+ <h3>Edit</h3>
2
+
3
+ {{partial '<%= file_name.pluralize -%>/form'}}
@@ -0,0 +1,9 @@
1
+ <% attributes.each do |attribute| -%>
2
+ <div>
3
+ <label for=""><%= attribute[:name].titleize -%></label>
4
+ {{input value=<%= attribute[:name].camelize(:lower) -%>}}
5
+ </div>
6
+ <% end -%>
7
+
8
+ <button type="submit" {{action save}}>Save</button>
9
+ <button type="submit" {{action cancel}}>Cancel</button>
@@ -0,0 +1,20 @@
1
+ <h3>Index</h3>
2
+
3
+ <p>{{#link-to '<%= file_name.pluralize -%>.new'}}New <%= file_name.singularize -%>{{/link-to}}</p>
4
+
5
+ <table>
6
+ <tr>
7
+ <th>id</th>
8
+ <% attributes.each do |attribute| -%>
9
+ <th><%= attribute[:name].titleize -%></th>
10
+ <% end -%>
11
+ </tr>
12
+ {{#each}}
13
+ <tr>
14
+ <td>{{#link-to '<%= file_name.pluralize -%>.show' this}}{{id}}{{/link-to}}</td>
15
+ <% attributes.each do |attribute| -%>
16
+ <td>{{<%= attribute[:name] -%>}}</td>
17
+ <% end -%>
18
+ </tr>
19
+ {{/each}}
20
+ </table>
@@ -0,0 +1,3 @@
1
+ <h3>New</h3>
2
+
3
+ {{partial '<%= file_name.pluralize -%>/form'}}
@@ -0,0 +1,9 @@
1
+ <h3>{{id}}</h3>
2
+
3
+ <p>{{#link-to '<%= file_name.pluralize -%>.edit' this}}Edit{{/link-to}} <button {{action destroyRecord}}>Destroy</button></p>
4
+
5
+ <ul>
6
+ <% attributes.each do |attribute| -%>
7
+ <li><%= attribute[:name].titleize -%>: {{<%= attribute[:name] -%>}}</li>
8
+ <% end -%>
9
+ </ul>
@@ -1,5 +0,0 @@
1
- <h1><%= class_name %></h1>
2
-
3
- <p>Your content here.</p>
4
-
5
- {{outlet}}
@@ -1,3 +1,2 @@
1
- export default = Ember.View.extend({
2
-
1
+ export default Ember.View.extend({
3
2
  });
@@ -0,0 +1,40 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '4.0.1'
5
+
6
+
7
+ # Use SCSS for stylesheets
8
+ gem 'sass-rails', '~> 4.0.0'
9
+
10
+ # Use Uglifier as compressor for JavaScript assets
11
+ gem 'uglifier', '>= 1.3.0'
12
+
13
+ # Use CoffeeScript for .js.coffee assets and views
14
+ gem 'coffee-rails', '~> 4.0.0'
15
+
16
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
17
+ # gem 'therubyracer', platforms: :ruby
18
+
19
+ # Use jquery as the JavaScript library
20
+ gem 'jquery-rails'
21
+
22
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
23
+ gem 'jbuilder', '~> 1.2'
24
+
25
+ group :doc do
26
+ # bundle exec rake doc:rails generates the API under doc/api.
27
+ gem 'sdoc', require: false
28
+ end
29
+
30
+ # Use ActiveModel has_secure_password
31
+ # gem 'bcrypt-ruby', '~> 3.1.2'
32
+
33
+ # Use unicorn as the app server
34
+ # gem 'unicorn'
35
+
36
+ # Use Capistrano for deployment
37
+ # gem 'capistrano', group: :development
38
+
39
+ # Use debugger
40
+ # gem 'debugger', group: [:development, :test]
@@ -0,0 +1,3 @@
1
+ window.App.ApplicationAdapter = DS.ActiveModelAdapter.extend({
2
+ namespace: 'api/v1'
3
+ });
@@ -0,0 +1,11 @@
1
+ //= require jquery
2
+ //= require environment
3
+ //= require ember-appkit
4
+ //= require ember-data
5
+ //= require_self
6
+ //= require adapter
7
+ //= require router
8
+ //= require_tree ../app
9
+ //= require_tree ./initializers
10
+
11
+ window.App = require('app').default.create();