railties 4.2.11.3 → 5.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +262 -206
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +1 -1
  5. data/{bin → exe}/rails +0 -0
  6. data/lib/rails.rb +19 -1
  7. data/lib/rails/all.rb +10 -9
  8. data/lib/rails/api/task.rb +7 -14
  9. data/lib/rails/{app_rails_loader.rb → app_loader.rb} +4 -3
  10. data/lib/rails/application.rb +31 -41
  11. data/lib/rails/application/bootstrap.rb +1 -14
  12. data/lib/rails/application/configuration.rb +94 -95
  13. data/lib/rails/application/default_middleware_stack.rb +30 -16
  14. data/lib/rails/application/finisher.rb +11 -2
  15. data/lib/rails/application/routes_reloader.rb +1 -3
  16. data/lib/rails/application_controller.rb +1 -1
  17. data/lib/rails/cli.rb +2 -2
  18. data/lib/rails/code_statistics.rb +6 -8
  19. data/lib/rails/code_statistics_calculator.rb +8 -1
  20. data/lib/rails/command.rb +70 -0
  21. data/lib/rails/commands.rb +5 -3
  22. data/lib/rails/commands/commands_tasks.rb +25 -14
  23. data/lib/rails/commands/console.rb +7 -52
  24. data/lib/rails/commands/console_helper.rb +34 -0
  25. data/lib/rails/commands/dbconsole.rb +59 -78
  26. data/lib/rails/commands/dev_cache.rb +21 -0
  27. data/lib/rails/commands/plugin.rb +1 -1
  28. data/lib/rails/commands/rake_proxy.rb +34 -0
  29. data/lib/rails/commands/runner.rb +0 -1
  30. data/lib/rails/commands/server.rb +29 -36
  31. data/lib/rails/commands/test.rb +9 -0
  32. data/lib/rails/configuration.rb +21 -5
  33. data/lib/rails/console/app.rb +5 -0
  34. data/lib/rails/console/helpers.rb +1 -1
  35. data/lib/rails/engine.rb +68 -58
  36. data/lib/rails/engine/commands.rb +4 -2
  37. data/lib/rails/engine/configuration.rb +4 -10
  38. data/lib/rails/gem_version.rb +4 -4
  39. data/lib/rails/generators.rb +30 -7
  40. data/lib/rails/generators/.named_base.rb.swp +0 -0
  41. data/lib/rails/generators/actions.rb +19 -5
  42. data/lib/rails/generators/app_base.rb +65 -45
  43. data/lib/rails/generators/base.rb +6 -6
  44. data/lib/rails/generators/erb/mailer/mailer_generator.rb +5 -8
  45. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +9 -7
  46. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb +1 -1
  47. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +2 -2
  48. data/lib/rails/generators/erb/scaffold/templates/new.html.erb +1 -1
  49. data/lib/rails/generators/generated_attribute.rb +5 -1
  50. data/lib/rails/generators/migration.rb +7 -7
  51. data/lib/rails/generators/named_base.rb +21 -5
  52. data/lib/rails/generators/rails/app/USAGE +0 -1
  53. data/lib/rails/generators/rails/app/app_generator.rb +75 -11
  54. data/lib/rails/generators/rails/app/templates/Gemfile +17 -13
  55. data/lib/rails/generators/rails/app/templates/{README.rdoc → README.md} +1 -5
  56. data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +7 -0
  57. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +1 -1
  58. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.coffee +11 -0
  59. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +3 -3
  60. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb +5 -0
  61. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb +5 -0
  62. data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +3 -1
  63. data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb +2 -0
  64. data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb +4 -0
  65. data/lib/rails/generators/rails/app/templates/app/models/application_record.rb +3 -0
  66. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +20 -17
  67. data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +13 -0
  68. data/lib/rails/generators/{erb/mailer/templates/layout.text.erb → rails/app/templates/app/views/layouts/mailer.text.erb.tt} +0 -0
  69. data/lib/rails/generators/rails/app/templates/bin/setup +17 -12
  70. data/lib/rails/generators/rails/app/templates/bin/update +28 -0
  71. data/lib/rails/generators/rails/app/templates/config.ru.tt +11 -0
  72. data/lib/rails/generators/rails/app/templates/config/application.rb +9 -14
  73. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +1 -1
  74. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +2 -2
  75. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +20 -3
  76. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +18 -11
  77. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +7 -3
  78. data/lib/rails/generators/rails/app/templates/config/initializers/active_record_belongs_to_required_by_default.rb +5 -0
  79. data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb +6 -0
  80. data/lib/rails/generators/rails/app/templates/config/initializers/callback_terminator.rb +5 -0
  81. data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb +1 -0
  82. data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb +16 -0
  83. data/lib/rails/generators/rails/app/templates/config/initializers/request_forgery_protection.rb +4 -0
  84. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +2 -2
  85. data/lib/rails/generators/rails/app/templates/config/redis/cable.yml +9 -0
  86. data/lib/rails/generators/rails/app/templates/config/routes.rb +3 -53
  87. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +3 -3
  88. data/lib/rails/generators/rails/app/templates/gitignore +7 -1
  89. data/lib/rails/generators/rails/controller/controller_generator.rb +6 -4
  90. data/lib/rails/generators/rails/migration/migration_generator.rb +1 -1
  91. data/lib/rails/generators/rails/model/USAGE +6 -1
  92. data/lib/rails/generators/rails/model/model_generator.rb +1 -1
  93. data/lib/rails/generators/rails/plugin/plugin_generator.rb +88 -35
  94. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec +6 -9
  95. data/lib/rails/generators/rails/plugin/templates/Gemfile +3 -7
  96. data/lib/rails/generators/rails/plugin/templates/README.md +3 -0
  97. data/lib/rails/generators/rails/plugin/templates/Rakefile +2 -2
  98. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +5 -0
  99. data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
  100. data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +5 -0
  101. data/lib/rails/generators/rails/plugin/templates/app/models/application_record.rb.tt +6 -0
  102. data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +14 -0
  103. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -1
  104. data/lib/rails/generators/rails/plugin/templates/bin/test.tt +8 -0
  105. data/lib/rails/generators/rails/plugin/templates/config/routes.rb +1 -1
  106. data/lib/rails/generators/rails/plugin/templates/gitignore +2 -3
  107. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb +5 -0
  108. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb +7 -0
  109. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb +1 -0
  110. data/lib/rails/generators/rails/plugin/templates/lib/tasks/{%name%_tasks.rake → %namespaced_name%_tasks.rake} +1 -1
  111. data/lib/rails/generators/rails/plugin/templates/rails/application.rb +3 -3
  112. data/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js +11 -0
  113. data/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js +6 -0
  114. data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js +1 -1
  115. data/lib/rails/generators/rails/plugin/templates/rails/routes.rb +1 -2
  116. data/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +3 -3
  117. data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb +7 -0
  118. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +4 -2
  119. data/lib/rails/generators/rails/resource/resource_generator.rb +0 -1
  120. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +0 -1
  121. data/lib/rails/generators/rails/scaffold/USAGE +1 -1
  122. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
  123. data/lib/rails/generators/rails/scaffold/templates/scaffold.css +35 -7
  124. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +4 -1
  125. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb +61 -0
  126. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
  127. data/lib/rails/generators/resource_helpers.rb +3 -3
  128. data/lib/rails/generators/test_unit/controller/templates/.functional_test.rb.swp +0 -0
  129. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +3 -5
  130. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +8 -3
  131. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +2 -2
  132. data/lib/rails/generators/test_unit/mailer/templates/preview.rb +4 -4
  133. data/lib/rails/generators/test_unit/model/model_generator.rb +1 -1
  134. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +2 -0
  135. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +5 -1
  136. data/lib/rails/generators/test_unit/scaffold/templates/.api_functional_test.rb.swp +0 -0
  137. data/lib/rails/generators/test_unit/scaffold/templates/.functional_test.rb.swp +0 -0
  138. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb +44 -0
  139. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +14 -14
  140. data/lib/rails/generators/testing/assertions.rb +0 -2
  141. data/lib/rails/generators/testing/behaviour.rb +4 -17
  142. data/lib/rails/info.rb +2 -2
  143. data/lib/rails/info_controller.rb +23 -2
  144. data/lib/rails/mailers_controller.rb +2 -2
  145. data/lib/rails/paths.rb +14 -6
  146. data/lib/rails/rack.rb +1 -3
  147. data/lib/rails/rack/debugger.rb +2 -23
  148. data/lib/rails/rack/logger.rb +4 -0
  149. data/lib/rails/ruby_version_check.rb +3 -3
  150. data/lib/rails/source_annotation_extractor.rb +1 -1
  151. data/lib/rails/tasks.rb +4 -1
  152. data/lib/rails/tasks/engine.rake +1 -1
  153. data/lib/rails/tasks/framework.rake +18 -16
  154. data/lib/rails/tasks/initializers.rake +6 -0
  155. data/lib/rails/tasks/restart.rake +5 -0
  156. data/lib/rails/tasks/statistics.rake +5 -6
  157. data/lib/rails/tasks/tmp.rake +4 -12
  158. data/lib/rails/templates/rails/mailers/email.html.erb +17 -3
  159. data/lib/rails/templates/rails/welcome/index.html.erb +10 -3
  160. data/lib/rails/test_help.rb +7 -8
  161. data/lib/rails/test_unit/minitest_plugin.rb +91 -0
  162. data/lib/rails/test_unit/reporter.rb +74 -0
  163. data/lib/rails/test_unit/test_requirer.rb +28 -0
  164. data/lib/rails/test_unit/testing.rake +18 -39
  165. metadata +80 -33
  166. data/lib/rails/deprecation.rb +0 -19
  167. data/lib/rails/generators/erb/mailer/templates/layout.html.erb +0 -5
  168. data/lib/rails/generators/rails/app/templates/config.ru +0 -4
  169. data/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb +0 -10
  170. data/lib/rails/generators/rails/plugin/templates/README.rdoc +0 -3
  171. data/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt +0 -5
  172. data/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt +0 -4
  173. data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt +0 -14
  174. data/lib/rails/generators/rails/plugin/templates/lib/%name%.rb +0 -6
  175. data/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb +0 -7
  176. data/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb +0 -3
  177. data/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb +0 -7
  178. data/lib/rails/rack/log_tailer.rb +0 -38
  179. data/lib/rails/tasks/documentation.rake +0 -70
  180. data/lib/rails/test_unit/sub_test_task.rb +0 -126
@@ -18,8 +18,8 @@ module Rails
18
18
  parse_attributes! if respond_to?(:attributes)
19
19
  end
20
20
 
21
- # Defines the template that would be used for the migration file.
22
- # The arguments include the source template file, the migration filename etc.
21
+ # Overrides <tt>Thor::Actions#template</tt> so it can tell if
22
+ # a template is currently being created.
23
23
  no_tasks do
24
24
  def template(source, *args, &block)
25
25
  inside_template do
@@ -99,7 +99,7 @@ module Rails
99
99
  end
100
100
 
101
101
  def class_name
102
- (class_path + [file_name]).map!{ |m| m.camelize }.join('::')
102
+ (class_path + [file_name]).map!(&:camelize).join('::')
103
103
  end
104
104
 
105
105
  def human_name
@@ -129,6 +129,18 @@ module Rails
129
129
  uncountable? ? "#{plural_table_name}_index" : plural_table_name
130
130
  end
131
131
 
132
+ def show_helper
133
+ "#{singular_table_name}_url(@#{singular_table_name})"
134
+ end
135
+
136
+ def edit_helper
137
+ "edit_#{show_helper}"
138
+ end
139
+
140
+ def new_helper
141
+ "new_#{singular_table_name}_url"
142
+ end
143
+
132
144
  def singular_table_name
133
145
  @singular_table_name ||= (pluralize_table_names? ? table_name.singularize : table_name)
134
146
  end
@@ -141,11 +153,15 @@ module Rails
141
153
  @plural_file_name ||= file_name.pluralize
142
154
  end
143
155
 
156
+ def fixture_file_name
157
+ @fixture_file_name ||= (pluralize_table_names? ? plural_file_name : file_name)
158
+ end
159
+
144
160
  def route_url
145
161
  @route_url ||= class_path.collect {|dname| "/" + dname }.join + "/" + plural_file_name
146
162
  end
147
163
 
148
- # Tries to retrieve the application name or simple return application.
164
+ # Tries to retrieve the application name or simply return application.
149
165
  def application_name
150
166
  if defined?(Rails) && Rails.application
151
167
  Rails.application.class.name.split('::').first.underscore
@@ -156,7 +172,7 @@ module Rails
156
172
 
157
173
  def assign_names!(name) #:nodoc:
158
174
  @class_path = name.include?('/') ? name.split('/') : name.split('::')
159
- @class_path.map! { |m| m.underscore }
175
+ @class_path.map!(&:underscore)
160
176
  @file_name = @class_path.pop
161
177
  end
162
178
 
@@ -12,4 +12,3 @@ Example:
12
12
  rails new ~/Code/Ruby/weblog
13
13
 
14
14
  This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
15
- See the README in the newly created application to get going.
@@ -38,7 +38,7 @@ module Rails
38
38
  end
39
39
 
40
40
  def readme
41
- copy_file "README.rdoc", "README.rdoc"
41
+ copy_file "README.md", "README.md"
42
42
  end
43
43
 
44
44
  def gemfile
@@ -57,8 +57,7 @@ module Rails
57
57
  directory 'app'
58
58
 
59
59
  keep_file 'app/assets/images'
60
- keep_file 'app/mailers'
61
- keep_file 'app/models'
60
+ keep_file 'app/assets/javascripts/channels' unless options[:skip_action_cable]
62
61
 
63
62
  keep_file 'app/controllers/concerns'
64
63
  keep_file 'app/models/concerns'
@@ -83,21 +82,27 @@ module Rails
83
82
  directory "environments"
84
83
  directory "initializers"
85
84
  directory "locales"
85
+ directory "redis" unless options[:skip_action_cable]
86
86
  end
87
87
  end
88
88
 
89
89
  def config_when_updating
90
90
  cookie_serializer_config_exist = File.exist?('config/initializers/cookies_serializer.rb')
91
- to_time_preserves_timezone_config_exist = File.exist?('config/initializers/to_time_preserves_timezone.rb')
91
+ callback_terminator_config_exist = File.exist?('config/initializers/callback_terminator.rb')
92
+ active_record_belongs_to_required_by_default_config_exist = File.exist?('config/initializers/active_record_belongs_to_required_by_default.rb')
92
93
 
93
94
  config
94
95
 
96
+ unless callback_terminator_config_exist
97
+ remove_file 'config/initializers/callback_terminator.rb'
98
+ end
99
+
95
100
  unless cookie_serializer_config_exist
96
101
  gsub_file 'config/initializers/cookies_serializer.rb', /json/, 'marshal'
97
102
  end
98
103
 
99
- unless to_time_preserves_timezone_config_exist
100
- remove_file 'config/initializers/to_time_preserves_timezone.rb'
104
+ unless active_record_belongs_to_required_by_default_config_exist
105
+ remove_file 'config/initializers/active_record_belongs_to_required_by_default.rb'
101
106
  end
102
107
  end
103
108
 
@@ -125,6 +130,7 @@ module Rails
125
130
 
126
131
  def test
127
132
  empty_directory_with_keep_file 'test/fixtures'
133
+ empty_directory_with_keep_file 'test/fixtures/files'
128
134
  empty_directory_with_keep_file 'test/controllers'
129
135
  empty_directory_with_keep_file 'test/mailers'
130
136
  empty_directory_with_keep_file 'test/models'
@@ -135,6 +141,7 @@ module Rails
135
141
  end
136
142
 
137
143
  def tmp
144
+ empty_directory_with_keep_file "tmp"
138
145
  empty_directory "tmp/cache"
139
146
  empty_directory "tmp/cache/assets"
140
147
  end
@@ -168,6 +175,9 @@ module Rails
168
175
  class_option :version, type: :boolean, aliases: "-v", group: :rails,
169
176
  desc: "Show Rails version number and quit"
170
177
 
178
+ class_option :api, type: :boolean,
179
+ desc: "Preconfigure smaller stack for API only apps"
180
+
171
181
  def initialize(*args)
172
182
  super
173
183
 
@@ -178,6 +188,10 @@ module Rails
178
188
  if !options[:skip_active_record] && !DATABASES.include?(options[:database])
179
189
  raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}."
180
190
  end
191
+
192
+ # Force sprockets to be skipped when generating API only apps.
193
+ # Can't modify options hash as it's frozen by default.
194
+ self.options = options.merge(skip_sprockets: true, skip_javascript: true).freeze if options[:api]
181
195
  end
182
196
 
183
197
  public_task :set_default_accessors!
@@ -234,7 +248,7 @@ module Rails
234
248
  end
235
249
 
236
250
  def create_test_files
237
- build(:test) unless options[:skip_test_unit]
251
+ build(:test) unless options[:skip_test]
238
252
  end
239
253
 
240
254
  def create_tmp_files
@@ -245,6 +259,28 @@ module Rails
245
259
  build(:vendor)
246
260
  end
247
261
 
262
+ def delete_app_assets_if_api_option
263
+ if options[:api]
264
+ remove_dir 'app/assets'
265
+ remove_dir 'lib/assets'
266
+ remove_dir 'tmp/cache/assets'
267
+ remove_dir 'vendor/assets'
268
+ end
269
+ end
270
+
271
+ def delete_app_helpers_if_api_option
272
+ if options[:api]
273
+ remove_dir 'app/helpers'
274
+ remove_dir 'test/helpers'
275
+ end
276
+ end
277
+
278
+ def delete_app_views_if_api_option
279
+ if options[:api]
280
+ remove_dir 'app/views'
281
+ end
282
+ end
283
+
248
284
  def delete_js_folder_skipping_javascript
249
285
  if options[:skip_javascript]
250
286
  remove_dir 'app/assets/javascripts'
@@ -257,6 +293,34 @@ module Rails
257
293
  end
258
294
  end
259
295
 
296
+ def delete_application_record_skipping_active_record
297
+ if options[:skip_active_record]
298
+ remove_file 'app/models/application_record.rb'
299
+ end
300
+ end
301
+
302
+ def delete_action_mailer_files_skipping_action_mailer
303
+ if options[:skip_action_mailer]
304
+ remove_file 'app/mailers/application_mailer.rb'
305
+ remove_file 'app/views/layouts/mailer.html.erb'
306
+ remove_file 'app/views/layouts/mailer.text.erb'
307
+ end
308
+ end
309
+
310
+ def delete_active_record_initializers_skipping_active_record
311
+ if options[:skip_active_record]
312
+ remove_file 'config/initializers/active_record_belongs_to_required_by_default.rb'
313
+ end
314
+ end
315
+
316
+ def delete_non_api_initializers_if_api_option
317
+ if options[:api]
318
+ remove_file 'config/initializers/session_store.rb'
319
+ remove_file 'config/initializers/cookies_serializer.rb'
320
+ remove_file 'config/initializers/request_forgery_protection.rb'
321
+ end
322
+ end
323
+
260
324
  def finish_template
261
325
  build(:leftovers)
262
326
  end
@@ -265,9 +329,7 @@ module Rails
265
329
  public_task :generate_spring_binstubs
266
330
 
267
331
  def run_after_bundle_callbacks
268
- @after_bundle_callbacks.each do |callback|
269
- callback.call
270
- end
332
+ @after_bundle_callbacks.each(&:call)
271
333
  end
272
334
 
273
335
  protected
@@ -309,7 +371,9 @@ module Rails
309
371
  if app_const =~ /^\d/
310
372
  raise Error, "Invalid application name #{app_name}. Please give a name which does not start with numbers."
311
373
  elsif RESERVED_NAMES.include?(app_name)
312
- raise Error, "Invalid application name #{app_name}. Please give a name which does not match one of the reserved rails words."
374
+ raise Error, "Invalid application name #{app_name}. Please give a " \
375
+ "name which does not match one of the reserved rails " \
376
+ "words: #{RESERVED_NAMES.join(", ")}"
313
377
  elsif Object.const_defined?(app_const_base)
314
378
  raise Error, "Invalid application name #{app_name}, constant #{app_const_base} is already in use. Please choose another application name."
315
379
  end
@@ -12,37 +12,41 @@ source 'https://rubygems.org'
12
12
  <% end -%>
13
13
  <% end -%>
14
14
 
15
+ # Use Puma as the app server
16
+ gem 'puma'
17
+
15
18
  # Use ActiveModel has_secure_password
16
19
  # gem 'bcrypt', '~> 3.1.7'
17
20
 
18
- # Use Unicorn as the app server
19
- # gem 'unicorn'
20
-
21
21
  # Use Capistrano for deployment
22
22
  # gem 'capistrano-rails', group: :development
23
23
 
24
- <% unless defined?(JRUBY_VERSION) -%>
24
+ <%- if options.api? -%>
25
+ # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
26
+ # gem 'rack-cors'
27
+
28
+ <%- end -%>
29
+ <% if RUBY_ENGINE == 'ruby' -%>
25
30
  group :development, :test do
26
- <%- if RUBY_VERSION < '2.0.0' -%>
27
- # Call 'debugger' anywhere in the code to stop execution and get a debugger console
28
- gem 'debugger'
29
- <%- else -%>
30
31
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
31
32
  gem 'byebug'
32
- <%- end -%>
33
33
  end
34
34
 
35
35
  group :development do
36
+ <%- unless options.api? -%>
36
37
  # Access an IRB console on exception pages or by using <%%= console %> in views
37
- gem 'web-console', '~> 2.0'
38
- <%- if spring_install? %>
38
+ <%- if options.dev? || options.edge? -%>
39
+ gem 'web-console', github: 'rails/web-console'
40
+ <%- else -%>
41
+ gem 'web-console', '~> 3.0'
42
+ <%- end -%>
43
+ <%- end -%>
44
+ <% if spring_install? -%>
39
45
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
40
46
  gem 'spring'
41
47
  <% end -%>
42
48
  end
43
49
  <% end -%>
44
50
 
45
- <% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%>
46
51
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
47
52
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
48
- <% end -%>
@@ -1,4 +1,4 @@
1
- == README
1
+ ## README
2
2
 
3
3
  This README would normally document whatever steps are necessary to get the
4
4
  application up and running.
@@ -22,7 +22,3 @@ Things you may want to cover:
22
22
  * Deployment instructions
23
23
 
24
24
  * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
@@ -0,0 +1,7 @@
1
+ <% unless options.api? -%>
2
+ //= link_tree ../images
3
+ <% end -%>
4
+ <% unless options.skip_javascript -%>
5
+ //= link_directory ../javascripts .js
6
+ <% end -%>
7
+ //= link_directory ../stylesheets .css
@@ -5,7 +5,7 @@
5
5
  // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
6
  //
7
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
9
  //
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
@@ -0,0 +1,11 @@
1
+ # Action Cable provides the framework to deal with WebSockets in Rails.
2
+ # You can generate new channels where WebSocket features live using the rails generate channel command.
3
+ #
4
+ # Turn on the cable connection by removing the comments after the require statements (and ensure it's also on in config/routes.rb).
5
+ #
6
+ #= require action_cable
7
+ #= require_self
8
+ #= require_tree ./channels
9
+ #
10
+ # @App ||= {}
11
+ # App.cable = ActionCable.createConsumer()
@@ -6,9 +6,9 @@
6
6
  * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
7
  *
8
8
  * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
12
  *
13
13
  *= require_tree .
14
14
  *= require_self
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file. Action Cable runs in an EventMachine loop that does not support auto reloading.
2
+ module ApplicationCable
3
+ class Channel < ActionCable::Channel::Base
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file. Action Cable runs in an EventMachine loop that does not support auto reloading.
2
+ module ApplicationCable
3
+ class Connection < ActionCable::Connection::Base
4
+ end
5
+ end
@@ -1,5 +1,7 @@
1
- class ApplicationController < ActionController::Base
1
+ class ApplicationController < ActionController::<%= options[:api] ? "API" : "Base" %>
2
+ <%- unless options[:api] -%>
2
3
  # Prevent CSRF attacks by raising an exception.
3
4
  # For APIs, you may want to use :null_session instead.
4
5
  protect_from_forgery with: :exception
6
+ <%- end -%>
5
7
  end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,23 +1,26 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title><%= camelized %></title>
5
- <%- if options[:skip_javascript] -%>
6
- <%%= stylesheet_link_tag 'application', media: 'all' %>
7
- <%- else -%>
8
- <%- if gemfile_entries.any? { |m| m.name == 'turbolinks' } -%>
9
- <%%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
10
- <%%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
11
- <%- else -%>
12
- <%%= stylesheet_link_tag 'application', media: 'all' %>
13
- <%%= javascript_include_tag 'application' %>
3
+ <head>
4
+ <title><%= camelized %></title>
5
+ <%%= csrf_meta_tags %>
6
+ <%- unless options[:skip_action_cable] -%>
7
+ <%%= action_cable_meta_tag %>
14
8
  <%- end -%>
15
- <%- end -%>
16
- <%%= csrf_meta_tags %>
17
- </head>
18
- <body>
19
9
 
20
- <%%= yield %>
10
+ <%- if options[:skip_javascript] -%>
11
+ <%%= stylesheet_link_tag 'application', media: 'all' %>
12
+ <%- else -%>
13
+ <%- if gemfile_entries.any? { |m| m.name == 'turbolinks' } -%>
14
+ <%%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
15
+ <%%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
16
+ <%- else -%>
17
+ <%%= stylesheet_link_tag 'application', media: 'all' %>
18
+ <%%= javascript_include_tag 'application' %>
19
+ <%- end -%>
20
+ <%- end -%>
21
+ </head>
21
22
 
22
- </body>
23
+ <body>
24
+ <%%= yield %>
25
+ </body>
23
26
  </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%%= yield %>
12
+ </body>
13
+ </html>