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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +262 -206
- data/MIT-LICENSE +20 -0
- data/README.rdoc +1 -1
- data/{bin → exe}/rails +0 -0
- data/lib/rails.rb +19 -1
- data/lib/rails/all.rb +10 -9
- data/lib/rails/api/task.rb +7 -14
- data/lib/rails/{app_rails_loader.rb → app_loader.rb} +4 -3
- data/lib/rails/application.rb +31 -41
- data/lib/rails/application/bootstrap.rb +1 -14
- data/lib/rails/application/configuration.rb +94 -95
- data/lib/rails/application/default_middleware_stack.rb +30 -16
- data/lib/rails/application/finisher.rb +11 -2
- data/lib/rails/application/routes_reloader.rb +1 -3
- data/lib/rails/application_controller.rb +1 -1
- data/lib/rails/cli.rb +2 -2
- data/lib/rails/code_statistics.rb +6 -8
- data/lib/rails/code_statistics_calculator.rb +8 -1
- data/lib/rails/command.rb +70 -0
- data/lib/rails/commands.rb +5 -3
- data/lib/rails/commands/commands_tasks.rb +25 -14
- data/lib/rails/commands/console.rb +7 -52
- data/lib/rails/commands/console_helper.rb +34 -0
- data/lib/rails/commands/dbconsole.rb +59 -78
- data/lib/rails/commands/dev_cache.rb +21 -0
- data/lib/rails/commands/plugin.rb +1 -1
- data/lib/rails/commands/rake_proxy.rb +34 -0
- data/lib/rails/commands/runner.rb +0 -1
- data/lib/rails/commands/server.rb +29 -36
- data/lib/rails/commands/test.rb +9 -0
- data/lib/rails/configuration.rb +21 -5
- data/lib/rails/console/app.rb +5 -0
- data/lib/rails/console/helpers.rb +1 -1
- data/lib/rails/engine.rb +68 -58
- data/lib/rails/engine/commands.rb +4 -2
- data/lib/rails/engine/configuration.rb +4 -10
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators.rb +30 -7
- data/lib/rails/generators/.named_base.rb.swp +0 -0
- data/lib/rails/generators/actions.rb +19 -5
- data/lib/rails/generators/app_base.rb +65 -45
- data/lib/rails/generators/base.rb +6 -6
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +5 -8
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +9 -7
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +2 -2
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb +1 -1
- data/lib/rails/generators/generated_attribute.rb +5 -1
- data/lib/rails/generators/migration.rb +7 -7
- data/lib/rails/generators/named_base.rb +21 -5
- data/lib/rails/generators/rails/app/USAGE +0 -1
- data/lib/rails/generators/rails/app/app_generator.rb +75 -11
- data/lib/rails/generators/rails/app/templates/Gemfile +17 -13
- data/lib/rails/generators/rails/app/templates/{README.rdoc → README.md} +1 -5
- data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +7 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.coffee +11 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +3 -3
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb +5 -0
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb +5 -0
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +3 -1
- data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb +2 -0
- data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb +4 -0
- data/lib/rails/generators/rails/app/templates/app/models/application_record.rb +3 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +20 -17
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +13 -0
- data/lib/rails/generators/{erb/mailer/templates/layout.text.erb → rails/app/templates/app/views/layouts/mailer.text.erb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/bin/setup +17 -12
- data/lib/rails/generators/rails/app/templates/bin/update +28 -0
- data/lib/rails/generators/rails/app/templates/config.ru.tt +11 -0
- data/lib/rails/generators/rails/app/templates/config/application.rb +9 -14
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +2 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +20 -3
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +18 -11
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +7 -3
- data/lib/rails/generators/rails/app/templates/config/initializers/active_record_belongs_to_required_by_default.rb +5 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb +6 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/callback_terminator.rb +5 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb +1 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb +16 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/request_forgery_protection.rb +4 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/redis/cable.yml +9 -0
- data/lib/rails/generators/rails/app/templates/config/routes.rb +3 -53
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +3 -3
- data/lib/rails/generators/rails/app/templates/gitignore +7 -1
- data/lib/rails/generators/rails/controller/controller_generator.rb +6 -4
- data/lib/rails/generators/rails/migration/migration_generator.rb +1 -1
- data/lib/rails/generators/rails/model/USAGE +6 -1
- data/lib/rails/generators/rails/model/model_generator.rb +1 -1
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +88 -35
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec +6 -9
- data/lib/rails/generators/rails/plugin/templates/Gemfile +3 -7
- data/lib/rails/generators/rails/plugin/templates/README.md +3 -0
- data/lib/rails/generators/rails/plugin/templates/Rakefile +2 -2
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/models/application_record.rb.tt +6 -0
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +14 -0
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/bin/test.tt +8 -0
- data/lib/rails/generators/rails/plugin/templates/config/routes.rb +1 -1
- data/lib/rails/generators/rails/plugin/templates/gitignore +2 -3
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb +5 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb +7 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb +1 -0
- data/lib/rails/generators/rails/plugin/templates/lib/tasks/{%name%_tasks.rake → %namespaced_name%_tasks.rake} +1 -1
- data/lib/rails/generators/rails/plugin/templates/rails/application.rb +3 -3
- data/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js +11 -0
- data/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js +6 -0
- data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js +1 -1
- data/lib/rails/generators/rails/plugin/templates/rails/routes.rb +1 -2
- data/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +3 -3
- data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb +7 -0
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +4 -2
- data/lib/rails/generators/rails/resource/resource_generator.rb +0 -1
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +0 -1
- data/lib/rails/generators/rails/scaffold/USAGE +1 -1
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
- data/lib/rails/generators/rails/scaffold/templates/scaffold.css +35 -7
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +4 -1
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb +61 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
- data/lib/rails/generators/resource_helpers.rb +3 -3
- data/lib/rails/generators/test_unit/controller/templates/.functional_test.rb.swp +0 -0
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +3 -5
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +8 -3
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +2 -2
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb +4 -4
- data/lib/rails/generators/test_unit/model/model_generator.rb +1 -1
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml +2 -0
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +5 -1
- data/lib/rails/generators/test_unit/scaffold/templates/.api_functional_test.rb.swp +0 -0
- data/lib/rails/generators/test_unit/scaffold/templates/.functional_test.rb.swp +0 -0
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb +44 -0
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +14 -14
- data/lib/rails/generators/testing/assertions.rb +0 -2
- data/lib/rails/generators/testing/behaviour.rb +4 -17
- data/lib/rails/info.rb +2 -2
- data/lib/rails/info_controller.rb +23 -2
- data/lib/rails/mailers_controller.rb +2 -2
- data/lib/rails/paths.rb +14 -6
- data/lib/rails/rack.rb +1 -3
- data/lib/rails/rack/debugger.rb +2 -23
- data/lib/rails/rack/logger.rb +4 -0
- data/lib/rails/ruby_version_check.rb +3 -3
- data/lib/rails/source_annotation_extractor.rb +1 -1
- data/lib/rails/tasks.rb +4 -1
- data/lib/rails/tasks/engine.rake +1 -1
- data/lib/rails/tasks/framework.rake +18 -16
- data/lib/rails/tasks/initializers.rake +6 -0
- data/lib/rails/tasks/restart.rake +5 -0
- data/lib/rails/tasks/statistics.rake +5 -6
- data/lib/rails/tasks/tmp.rake +4 -12
- data/lib/rails/templates/rails/mailers/email.html.erb +17 -3
- data/lib/rails/templates/rails/welcome/index.html.erb +10 -3
- data/lib/rails/test_help.rb +7 -8
- data/lib/rails/test_unit/minitest_plugin.rb +91 -0
- data/lib/rails/test_unit/reporter.rb +74 -0
- data/lib/rails/test_unit/test_requirer.rb +28 -0
- data/lib/rails/test_unit/testing.rake +18 -39
- metadata +80 -33
- data/lib/rails/deprecation.rb +0 -19
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb +0 -5
- data/lib/rails/generators/rails/app/templates/config.ru +0 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/lib/rails/generators/rails/plugin/templates/README.rdoc +0 -3
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt +0 -5
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt +0 -4
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt +0 -14
- data/lib/rails/generators/rails/plugin/templates/lib/%name%.rb +0 -6
- data/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb +0 -7
- data/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb +0 -3
- data/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb +0 -7
- data/lib/rails/rack/log_tailer.rb +0 -38
- data/lib/rails/tasks/documentation.rake +0 -70
- 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
|
-
#
|
22
|
-
#
|
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!
|
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
|
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!
|
175
|
+
@class_path.map!(&:underscore)
|
160
176
|
@file_name = @class_path.pop
|
161
177
|
end
|
162
178
|
|
@@ -38,7 +38,7 @@ module Rails
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def readme
|
41
|
-
copy_file "README.
|
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/
|
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
|
-
|
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
|
100
|
-
remove_file 'config/initializers/
|
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[:
|
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
|
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
|
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
|
-
|
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
|
-
|
38
|
-
|
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
|
-
|
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>.
|
@@ -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
|
10
|
-
*
|
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
|
@@ -1,5 +1,7 @@
|
|
1
|
-
class ApplicationController < ActionController
|
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
|
@@ -1,23 +1,26 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
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
|
-
|
23
|
+
<body>
|
24
|
+
<%%= yield %>
|
25
|
+
</body>
|
23
26
|
</html>
|