railties 7.0.0.alpha1 → 7.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -1
- data/lib/rails/all.rb +0 -1
- data/lib/rails/app_updater.rb +1 -1
- data/lib/rails/application/bootstrap.rb +7 -3
- data/lib/rails/application/configuration.rb +18 -7
- data/lib/rails/application/default_middleware_stack.rb +3 -2
- data/lib/rails/application/finisher.rb +2 -3
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +0 -5
- data/lib/rails/engine/configuration.rb +1 -1
- data/lib/rails/engine.rb +3 -5
- data/lib/rails/gem_version.rb +1 -1
- data/lib/rails/generators/app_base.rb +44 -14
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +8 -8
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +2 -2
- data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +5 -5
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +1 -1
- data/lib/rails/generators/generated_attribute.rb +5 -5
- data/lib/rails/generators/rails/app/app_generator.rb +12 -6
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +14 -9
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +1 -0
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +0 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +4 -1
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +12 -2
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +19 -20
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +36 -0
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/gitignore.tt +3 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +1 -1
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +3 -1
- data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +0 -1
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +7 -9
- data/lib/rails/railtie.rb +18 -1
- data/lib/rails/tasks/yarn.rake +4 -9
- data/lib/rails/templates/rails/mailers/email.html.erb +1 -1
- data/lib/rails/test_unit/runner.rb +9 -4
- data/lib/rails/welcome_controller.rb +1 -0
- data/lib/rails.rb +4 -0
- metadata +20 -22
- data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +0 -8
- data/lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb.tt +0 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4faffb109d7c8de979dd145a095fb9ab2cecd14b0c04ba22a59bd993bbc876fc
|
4
|
+
data.tar.gz: a707973415707a90df0bef3b4d7ceee7394e567c1dcd7e502df793147fe82f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c05ecaa835e442827306d60819e5325fb49453764e8c3cdfeb9dd8e83356fd22e7ec7b8225daa7ab1b0e660a6381f9f76f62aec853b68c7591950952ab544342
|
7
|
+
data.tar.gz: 483f9b60ee65a85d338b34fcdd9847845c9a86b76bf28c6ca967fa9e16ea8e01d505f7093647e4c6d2cda8f22e1d7e5cfc171ceb06feed88e5900ff5dd2326ea
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,52 @@
|
|
1
|
+
## Rails 7.0.0.rc3 (December 14, 2021) ##
|
2
|
+
|
3
|
+
* Allow localhost with a port by default in development
|
4
|
+
|
5
|
+
[Fixes: #43864]
|
6
|
+
|
7
|
+
## Rails 7.0.0.rc2 (December 14, 2021) ##
|
8
|
+
|
9
|
+
* Remove deprecated `config` in `dbconsole`.
|
10
|
+
|
11
|
+
*Rafael Mendonça França*
|
12
|
+
|
13
|
+
* Change default `X-XSS-Protection` header to disable XSS auditor
|
14
|
+
|
15
|
+
This header has been deprecated and the XSS auditor it triggered
|
16
|
+
has been removed from all major modern browsers (in favour of
|
17
|
+
Content Security Policy) that implemented this header to begin with
|
18
|
+
(Firefox never did).
|
19
|
+
|
20
|
+
[OWASP](https://owasp.org/www-project-secure-headers/#x-xss-protection)
|
21
|
+
suggests setting this header to '0' to disable the default behaviour
|
22
|
+
on old browsers as it can introduce additional security issues.
|
23
|
+
|
24
|
+
Added the new behaviour as a framework default from Rails 7.0.
|
25
|
+
|
26
|
+
*Christian Sutter*
|
27
|
+
|
28
|
+
* Scaffolds now use date_field, time_field and datetime_field instead of
|
29
|
+
date_select, time_select and datetime_select; thus providing native date/time pickers.
|
30
|
+
|
31
|
+
*Martijn Lafeber*
|
32
|
+
|
33
|
+
* Fix a regression in which autoload paths were initialized too late.
|
34
|
+
|
35
|
+
*Xavier Noria*
|
36
|
+
|
37
|
+
## Rails 7.0.0.alpha2 (September 15, 2021) ##
|
38
|
+
|
39
|
+
* Fix activestorage dependency in the npm package.
|
40
|
+
|
41
|
+
*Rafael Mendonça França*
|
42
|
+
|
1
43
|
## Rails 7.0.0.alpha1 (September 15, 2021) ##
|
2
44
|
|
3
45
|
* New and upgraded Rails apps no longer generate `config/initializers/application_controller_renderer.rb`
|
4
46
|
or `config/initializers/cookies_serializer.rb`
|
5
47
|
|
6
48
|
The default value for `cookies_serializer` (`:json`) has been moved to `config.load_defaults("7.0")`.
|
7
|
-
The new framework defaults file
|
49
|
+
The new framework defaults file can be used to upgrade the serializer.
|
8
50
|
|
9
51
|
*Alex Ghiculescu*
|
10
52
|
|
data/lib/rails/all.rb
CHANGED
data/lib/rails/app_updater.rb
CHANGED
@@ -25,7 +25,7 @@ module Rails
|
|
25
25
|
options[:skip_active_storage] = !defined?(ActiveStorage::Engine) || !defined?(ActiveRecord::Railtie)
|
26
26
|
options[:skip_action_mailer] = !defined?(ActionMailer::Railtie)
|
27
27
|
options[:skip_action_cable] = !defined?(ActionCable::Engine)
|
28
|
-
options[:
|
28
|
+
options[:skip_asset_pipeline] = !defined?(Sprockets::Railtie) && !defined?(Propshaft::Railtie)
|
29
29
|
options[:skip_bootsnap] = !defined?(Bootsnap)
|
30
30
|
options[:updating] = true
|
31
31
|
options
|
@@ -14,6 +14,7 @@ module Rails
|
|
14
14
|
initializer :load_environment_hook, group: :all do end
|
15
15
|
|
16
16
|
initializer :load_active_support, group: :all do
|
17
|
+
ENV["RAILS_DISABLE_DEPRECATED_TO_S_CONVERSION"] = "true" if config.active_support.disable_to_s_conversion
|
17
18
|
require "active_support/all" unless config.active_support.bare
|
18
19
|
end
|
19
20
|
|
@@ -49,8 +50,11 @@ module Rails
|
|
49
50
|
)
|
50
51
|
logger
|
51
52
|
end
|
52
|
-
|
53
53
|
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
|
54
|
+
|
55
|
+
unless config.consider_all_requests_local
|
56
|
+
Rails.error.logger = Rails.logger
|
57
|
+
end
|
54
58
|
end
|
55
59
|
|
56
60
|
# Initialize cache early in the stack so railties can make use of it.
|
@@ -59,14 +63,14 @@ module Rails
|
|
59
63
|
Rails.cache = ActiveSupport::Cache.lookup_store(*config.cache_store)
|
60
64
|
|
61
65
|
if Rails.cache.respond_to?(:middleware)
|
62
|
-
config.middleware.
|
66
|
+
config.middleware.insert_before(::Rack::Runtime, Rails.cache.middleware)
|
63
67
|
end
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
67
71
|
# We setup the once autoloader this early so that engines and applications
|
68
72
|
# are able to autoload from these paths during initialization.
|
69
|
-
initializer :setup_once_autoloader do
|
73
|
+
initializer :setup_once_autoloader, after: :set_eager_load_paths, before: :bootstrap_hook do
|
70
74
|
autoloader = Rails.autoloaders.once
|
71
75
|
|
72
76
|
ActiveSupport::Dependencies.autoload_once_paths.freeze
|
@@ -21,7 +21,7 @@ module Rails
|
|
21
21
|
:read_encrypted_secrets, :log_level, :content_security_policy_report_only,
|
22
22
|
:content_security_policy_nonce_generator, :content_security_policy_nonce_directives,
|
23
23
|
:require_master_key, :credentials, :disable_sandbox, :add_autoload_paths_to_load_path,
|
24
|
-
:rake_eager_load
|
24
|
+
:rake_eager_load, :server_timing
|
25
25
|
|
26
26
|
attr_reader :encoding, :api_only, :loaded_config_version
|
27
27
|
|
@@ -33,7 +33,7 @@ module Rails
|
|
33
33
|
@filter_parameters = []
|
34
34
|
@filter_redirect = []
|
35
35
|
@helpers_paths = []
|
36
|
-
@hosts =
|
36
|
+
@hosts = Rails.env.development? ? ActionDispatch::HostAuthorization::ALLOWED_HOSTS_IN_DEVELOPMENT : []
|
37
37
|
@hosts.concat(ENV["RAILS_DEVELOPMENT_HOSTS"].to_s.split(",").map(&:strip)) if Rails.env.development?
|
38
38
|
@host_authorization = {}
|
39
39
|
@public_file_server = ActiveSupport::OrderedOptions.new
|
@@ -74,6 +74,7 @@ module Rails
|
|
74
74
|
@add_autoload_paths_to_load_path = true
|
75
75
|
@permissions_policy = nil
|
76
76
|
@rake_eager_load = false
|
77
|
+
@server_timing = false
|
77
78
|
end
|
78
79
|
|
79
80
|
# Loads default configurations. See {the result of the method for each version}[https://guides.rubyonrails.org/configuring.html#results-of-config-load-defaults].
|
@@ -160,7 +161,6 @@ module Rails
|
|
160
161
|
|
161
162
|
if respond_to?(:active_job)
|
162
163
|
active_job.retry_jitter = 0.15
|
163
|
-
active_job.skip_after_callbacks_if_terminated = true
|
164
164
|
end
|
165
165
|
|
166
166
|
if respond_to?(:action_dispatch)
|
@@ -198,14 +198,18 @@ module Rails
|
|
198
198
|
load_defaults "6.1"
|
199
199
|
|
200
200
|
if respond_to?(:action_dispatch)
|
201
|
+
action_dispatch.default_headers = {
|
202
|
+
"X-Frame-Options" => "SAMEORIGIN",
|
203
|
+
"X-XSS-Protection" => "0",
|
204
|
+
"X-Content-Type-Options" => "nosniff",
|
205
|
+
"X-Download-Options" => "noopen",
|
206
|
+
"X-Permitted-Cross-Domain-Policies" => "none",
|
207
|
+
"Referrer-Policy" => "strict-origin-when-cross-origin"
|
208
|
+
}
|
201
209
|
action_dispatch.return_only_request_media_type_on_content_type = false
|
202
210
|
action_dispatch.cookies_serializer = :json
|
203
211
|
end
|
204
212
|
|
205
|
-
if respond_to?(:action_controller)
|
206
|
-
action_controller.silence_disabled_session_errors = false
|
207
|
-
end
|
208
|
-
|
209
213
|
if respond_to?(:action_view)
|
210
214
|
action_view.button_to_generates_button_tag = true
|
211
215
|
action_view.apply_stylesheet_media_default = false
|
@@ -216,6 +220,10 @@ module Rails
|
|
216
220
|
active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
|
217
221
|
active_support.remove_deprecated_time_with_zone_name = true
|
218
222
|
active_support.cache_format_version = 7.0
|
223
|
+
active_support.use_rfc4122_namespaced_uuids = true
|
224
|
+
active_support.executor_around_test_case = true
|
225
|
+
active_support.isolation_level = :thread
|
226
|
+
active_support.disable_to_s_conversion = true
|
219
227
|
end
|
220
228
|
|
221
229
|
if respond_to?(:action_mailer)
|
@@ -233,10 +241,13 @@ module Rails
|
|
233
241
|
if respond_to?(:active_record)
|
234
242
|
active_record.verify_foreign_keys_for_fixtures = true
|
235
243
|
active_record.partial_inserts = false
|
244
|
+
active_record.automatic_scope_inversing = true
|
236
245
|
end
|
237
246
|
|
238
247
|
if respond_to?(:action_controller)
|
239
248
|
action_controller.raise_on_open_redirects = true
|
249
|
+
|
250
|
+
action_controller.wrap_parameters_by_default = true
|
240
251
|
end
|
241
252
|
else
|
242
253
|
raise "Unknown version #{target_version.to_s.inspect}"
|
@@ -13,7 +13,7 @@ module Rails
|
|
13
13
|
|
14
14
|
def build_stack
|
15
15
|
ActionDispatch::MiddlewareStack.new do |middleware|
|
16
|
-
middleware.use ::ActionDispatch::HostAuthorization, config.hosts,
|
16
|
+
middleware.use ::ActionDispatch::HostAuthorization, config.hosts, **config.host_authorization
|
17
17
|
|
18
18
|
if config.force_ssl
|
19
19
|
middleware.use ::ActionDispatch::SSL, **config.ssl_options,
|
@@ -42,7 +42,8 @@ module Rails
|
|
42
42
|
|
43
43
|
middleware.use ::ActionDispatch::Executor, app.executor
|
44
44
|
|
45
|
-
middleware.use ::ActionDispatch::
|
45
|
+
middleware.use ::ActionDispatch::ServerTiming if config.server_timing
|
46
|
+
middleware.use ::Rack::Runtime
|
46
47
|
middleware.use ::Rack::MethodOverride unless config.api_only
|
47
48
|
middleware.use ::ActionDispatch::RequestId, header: config.action_dispatch.request_id_header
|
48
49
|
middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
|
@@ -176,9 +176,7 @@ module Rails
|
|
176
176
|
initializer :set_clear_dependencies_hook, group: :all do |app|
|
177
177
|
callback = lambda do
|
178
178
|
# Order matters.
|
179
|
-
ActiveSupport::DescendantsTracker.clear(
|
180
|
-
only: ActiveSupport::Dependencies._autoloaded_tracked_classes
|
181
|
-
)
|
179
|
+
ActiveSupport::DescendantsTracker.clear(ActiveSupport::Dependencies._autoloaded_tracked_classes)
|
182
180
|
ActiveSupport::Dependencies.clear
|
183
181
|
end
|
184
182
|
|
@@ -194,6 +192,7 @@ module Rails
|
|
194
192
|
|
195
193
|
if config.cache_classes
|
196
194
|
# No reloader
|
195
|
+
ActiveSupport::DescendantsTracker.disable_clear!
|
197
196
|
elsif config.reload_classes_only_on_change
|
198
197
|
reloader = config.file_watcher.new(*watchable_args, &callback)
|
199
198
|
reloaders << reloader
|
@@ -44,7 +44,7 @@ module Rails
|
|
44
44
|
exclude: ["assets", javascript_path]
|
45
45
|
paths.add "app/assets", glob: "*"
|
46
46
|
paths.add "app/controllers", eager_load: true
|
47
|
-
paths.add "app/channels", eager_load: true
|
47
|
+
paths.add "app/channels", eager_load: true
|
48
48
|
paths.add "app/helpers", eager_load: true
|
49
49
|
paths.add "app/models", eager_load: true
|
50
50
|
paths.add "app/mailers", eager_load: true
|
data/lib/rails/engine.rb
CHANGED
@@ -570,14 +570,12 @@ module Rails
|
|
570
570
|
$LOAD_PATH.uniq!
|
571
571
|
end
|
572
572
|
|
573
|
-
initializer :
|
574
|
-
|
573
|
+
initializer :set_autoload_paths, before: :bootstrap_hook do
|
574
|
+
ActiveSupport::Dependencies.autoload_paths.unshift(*_all_autoload_paths)
|
575
575
|
ActiveSupport::Dependencies.autoload_once_paths.unshift(*_all_autoload_once_paths)
|
576
|
-
end
|
577
576
|
|
578
|
-
initializer :set_autoload_paths, before: :setup_main_autoloader do
|
579
577
|
config.autoload_paths.freeze
|
580
|
-
|
578
|
+
config.autoload_once_paths.freeze
|
581
579
|
end
|
582
580
|
|
583
581
|
initializer :set_eager_load_paths, before: :bootstrap_hook do
|
data/lib/rails/gem_version.rb
CHANGED
@@ -58,8 +58,10 @@ module Rails
|
|
58
58
|
class_option :skip_action_cable, type: :boolean, aliases: "-C", default: false,
|
59
59
|
desc: "Skip Action Cable files"
|
60
60
|
|
61
|
-
class_option :
|
62
|
-
|
61
|
+
class_option :skip_asset_pipeline, type: :boolean, aliases: "-A", default: false
|
62
|
+
|
63
|
+
class_option :asset_pipeline, type: :string, aliases: "-a", default: "sprockets",
|
64
|
+
desc: "Choose your asset pipeline [options: sprockets (default), propshaft]"
|
63
65
|
|
64
66
|
class_option :skip_javascript, type: :boolean, aliases: "-J", default: name == "plugin",
|
65
67
|
desc: "Skip JavaScript files"
|
@@ -106,6 +108,7 @@ module Rails
|
|
106
108
|
private
|
107
109
|
def gemfile_entries # :doc:
|
108
110
|
[rails_gemfile_entry,
|
111
|
+
asset_pipeline_gemfile_entry,
|
109
112
|
database_gemfile_entry,
|
110
113
|
web_server_gemfile_entry,
|
111
114
|
javascript_gemfile_entry,
|
@@ -148,7 +151,7 @@ module Rails
|
|
148
151
|
when /^https?:\/\//
|
149
152
|
options[:template]
|
150
153
|
when String
|
151
|
-
File.expand_path(options[:template]
|
154
|
+
File.expand_path(`echo #{options[:template]}`.strip)
|
152
155
|
else
|
153
156
|
options[:template]
|
154
157
|
end
|
@@ -165,13 +168,25 @@ module Rails
|
|
165
168
|
GemfileEntry.new "puma", "~> 5.0", "Use the Puma web server [https://github.com/puma/puma]"
|
166
169
|
end
|
167
170
|
|
171
|
+
def asset_pipeline_gemfile_entry
|
172
|
+
return [] if options[:skip_asset_pipeline]
|
173
|
+
|
174
|
+
if options[:asset_pipeline] == "sprockets"
|
175
|
+
GemfileEntry.version "sprockets-rails", ">= 3.4.1",
|
176
|
+
"The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]"
|
177
|
+
elsif options[:asset_pipeline] == "propshaft"
|
178
|
+
GemfileEntry.version "propshaft", ">= 0.4.1", "The modern asset pipeline for Rails [https://github.com/rails/propshaft/]"
|
179
|
+
else
|
180
|
+
[]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
168
184
|
def include_all_railties? # :doc:
|
169
185
|
[
|
170
186
|
options.values_at(
|
171
187
|
:skip_active_record,
|
172
188
|
:skip_action_mailer,
|
173
189
|
:skip_test,
|
174
|
-
:skip_sprockets,
|
175
190
|
:skip_action_cable,
|
176
191
|
:skip_active_job
|
177
192
|
),
|
@@ -218,6 +233,11 @@ module Rails
|
|
218
233
|
options[:skip_dev_gems]
|
219
234
|
end
|
220
235
|
|
236
|
+
def skip_sprockets?
|
237
|
+
options[:skip_asset_pipeline] || options[:asset_pipeline] != "sprockets"
|
238
|
+
end
|
239
|
+
|
240
|
+
|
221
241
|
class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)
|
222
242
|
def initialize(name, version, comment, options = {}, commented_out = false)
|
223
243
|
super
|
@@ -287,16 +307,16 @@ module Rails
|
|
287
307
|
def jbuilder_gemfile_entry
|
288
308
|
return [] if options[:skip_jbuilder]
|
289
309
|
comment = "Build JSON APIs with ease [https://github.com/rails/jbuilder]"
|
290
|
-
GemfileEntry.new "jbuilder", "~> 2.
|
310
|
+
GemfileEntry.new "jbuilder", "~> 2.11", comment, {}, options[:api]
|
291
311
|
end
|
292
312
|
|
293
313
|
def javascript_gemfile_entry
|
294
314
|
return [] if options[:skip_javascript]
|
295
315
|
|
296
|
-
if
|
297
|
-
GemfileEntry.version("importmap-rails", ">= 0.
|
316
|
+
if adjusted_javascript_option == "importmap"
|
317
|
+
GemfileEntry.version("importmap-rails", ">= 0.9.2", "Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]")
|
298
318
|
else
|
299
|
-
GemfileEntry.version "jsbundling-rails", "
|
319
|
+
GemfileEntry.version "jsbundling-rails", ">= 0.2.2", "Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]"
|
300
320
|
end
|
301
321
|
end
|
302
322
|
|
@@ -304,10 +324,10 @@ module Rails
|
|
304
324
|
return [] if options[:skip_javascript] || options[:skip_hotwire]
|
305
325
|
|
306
326
|
turbo_rails_entry =
|
307
|
-
GemfileEntry.version("turbo-rails", ">= 0.
|
327
|
+
GemfileEntry.version("turbo-rails", ">= 0.9.0", "Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]")
|
308
328
|
|
309
329
|
stimulus_rails_entry =
|
310
|
-
GemfileEntry.version("stimulus-rails", ">= 0.
|
330
|
+
GemfileEntry.version("stimulus-rails", ">= 0.7.3", "Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]")
|
311
331
|
|
312
332
|
[ turbo_rails_entry, stimulus_rails_entry ]
|
313
333
|
end
|
@@ -316,13 +336,23 @@ module Rails
|
|
316
336
|
options[:javascript] && options[:javascript] != "importmap"
|
317
337
|
end
|
318
338
|
|
339
|
+
# CSS processors other than Tailwind require a node-based JavaScript environment. So overwrite the normal JS default
|
340
|
+
# if one such processor has been specified.
|
341
|
+
def adjusted_javascript_option
|
342
|
+
if options[:css] && options[:css] != "tailwind" && options[:javascript] == "importmap"
|
343
|
+
"esbuild"
|
344
|
+
else
|
345
|
+
options[:javascript]
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
319
349
|
def css_gemfile_entry
|
320
350
|
return [] unless options[:css]
|
321
351
|
|
322
352
|
if !using_node? && options[:css] == "tailwind"
|
323
|
-
GemfileEntry.version("tailwindcss-rails", ">= 0.
|
353
|
+
GemfileEntry.version("tailwindcss-rails", ">= 0.5.3", "Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]")
|
324
354
|
else
|
325
|
-
GemfileEntry.version("cssbundling-rails", ">= 0.
|
355
|
+
GemfileEntry.version("cssbundling-rails", ">= 0.2.7", "Bundle and process CSS [https://github.com/rails/cssbundling-rails]")
|
326
356
|
end
|
327
357
|
end
|
328
358
|
|
@@ -387,9 +417,9 @@ module Rails
|
|
387
417
|
def run_javascript
|
388
418
|
return if options[:skip_javascript] || !bundle_install?
|
389
419
|
|
390
|
-
case
|
420
|
+
case adjusted_javascript_option
|
391
421
|
when "importmap" then rails_command "importmap:install"
|
392
|
-
when "webpack", "esbuild", "rollup" then rails_command "javascript:install:#{
|
422
|
+
when "webpack", "esbuild", "rollup" then rails_command "javascript:install:#{adjusted_javascript_option}"
|
393
423
|
end
|
394
424
|
end
|
395
425
|
|
@@ -22,7 +22,7 @@ module Erb # :nodoc:
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
template "partial.html.erb", File.join("app/views", controller_file_path, "_#{
|
25
|
+
template "partial.html.erb", File.join("app/views", controller_file_path, "_#{singular_name}.html.erb")
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%%= form_with(model: <%= model_resource_name %>) do |form| %>
|
2
2
|
<%% if <%= singular_table_name %>.errors.any? %>
|
3
|
-
<div
|
3
|
+
<div style="color: red">
|
4
4
|
<h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
5
5
|
|
6
6
|
<ul>
|
@@ -12,26 +12,26 @@
|
|
12
12
|
<%% end %>
|
13
13
|
|
14
14
|
<% attributes.each do |attribute| -%>
|
15
|
-
<div
|
15
|
+
<div>
|
16
16
|
<% if attribute.password_digest? -%>
|
17
|
-
<%%= form.label :password %>
|
17
|
+
<%%= form.label :password, style: "display: block" %>
|
18
18
|
<%%= form.password_field :password %>
|
19
19
|
</div>
|
20
20
|
|
21
|
-
<div
|
22
|
-
<%%= form.label :password_confirmation %>
|
21
|
+
<div>
|
22
|
+
<%%= form.label :password_confirmation, style: "display: block" %>
|
23
23
|
<%%= form.password_field :password_confirmation %>
|
24
24
|
<% elsif attribute.attachments? -%>
|
25
|
-
<%%= form.label :<%= attribute.column_name
|
25
|
+
<%%= form.label :<%= attribute.column_name %>, style: "display: block" %>
|
26
26
|
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true %>
|
27
27
|
<% else -%>
|
28
|
-
<%%= form.label :<%= attribute.column_name
|
28
|
+
<%%= form.label :<%= attribute.column_name %>, style: "display: block" %>
|
29
29
|
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %> %>
|
30
30
|
<% end -%>
|
31
31
|
</div>
|
32
32
|
|
33
33
|
<% end -%>
|
34
|
-
<div
|
34
|
+
<div>
|
35
35
|
<%%= form.submit %>
|
36
36
|
</div>
|
37
37
|
<%% end %>
|
@@ -1,20 +1,20 @@
|
|
1
|
-
<div id="<%%= dom_id <%=
|
1
|
+
<div id="<%%= dom_id <%= singular_name %> %>">
|
2
2
|
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
3
3
|
<p>
|
4
4
|
<strong><%= attribute.human_name %>:</strong>
|
5
5
|
<% if attribute.attachment? -%>
|
6
|
-
<%%= link_to <%=
|
6
|
+
<%%= link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %> if <%= singular_name %>.<%= attribute.column_name %>.attached? %>
|
7
7
|
<% elsif attribute.attachments? -%>
|
8
|
-
<%% <%=
|
8
|
+
<%% <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
|
9
9
|
<div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div>
|
10
10
|
<%% end %>
|
11
11
|
<% else -%>
|
12
|
-
<%%= <%=
|
12
|
+
<%%= <%= singular_name %>.<%= attribute.column_name %> %>
|
13
13
|
<% end -%>
|
14
14
|
</p>
|
15
15
|
|
16
16
|
<% end -%>
|
17
17
|
<p>
|
18
|
-
<%%= link_to "Show this <%= human_name.downcase %>", <%=
|
18
|
+
<%%= link_to "Show this <%= human_name.downcase %>", <%= singular_name %> %>
|
19
19
|
</p>
|
20
20
|
</div>
|
@@ -106,9 +106,9 @@ module Rails
|
|
106
106
|
@field_type ||= case type
|
107
107
|
when :integer then :number_field
|
108
108
|
when :float, :decimal then :text_field
|
109
|
-
when :time then :
|
110
|
-
when :datetime, :timestamp then :
|
111
|
-
when :date then :
|
109
|
+
when :time then :time_field
|
110
|
+
when :datetime, :timestamp then :datetime_field
|
111
|
+
when :date then :date_field
|
112
112
|
when :text then :text_area
|
113
113
|
when :rich_text then :rich_text_area
|
114
114
|
when :boolean then :check_box
|
@@ -123,8 +123,8 @@ module Rails
|
|
123
123
|
when :integer then 1
|
124
124
|
when :float then 1.5
|
125
125
|
when :decimal then "9.99"
|
126
|
-
when :datetime, :timestamp, :time then Time.now.
|
127
|
-
when :date then Date.today.
|
126
|
+
when :datetime, :timestamp, :time then Time.now.to_formatted_s(:db)
|
127
|
+
when :date then Date.today.to_formatted_s(:db)
|
128
128
|
when :string then name == "type" ? "" : "MyString"
|
129
129
|
when :text then "MyText"
|
130
130
|
when :boolean then false
|
@@ -138,15 +138,15 @@ module Rails
|
|
138
138
|
template "config/storage.yml"
|
139
139
|
end
|
140
140
|
|
141
|
-
if
|
141
|
+
if skip_sprockets? && !assets_config_exist
|
142
142
|
remove_file "config/initializers/assets.rb"
|
143
143
|
end
|
144
144
|
|
145
|
-
if
|
145
|
+
if skip_sprockets? && !asset_manifest_exist
|
146
146
|
remove_file "app/assets/config/manifest.js"
|
147
147
|
end
|
148
148
|
|
149
|
-
if
|
149
|
+
if skip_sprockets? && !asset_app_stylesheet_exist
|
150
150
|
remove_file "app/assets/stylesheets/application.css"
|
151
151
|
end
|
152
152
|
|
@@ -163,6 +163,10 @@ module Rails
|
|
163
163
|
remove_file "config/initializers/permissions_policy.rb"
|
164
164
|
end
|
165
165
|
end
|
166
|
+
|
167
|
+
if !skip_sprockets?
|
168
|
+
insert_into_file "config/application.rb", %(require "sprockets/railtie"), after: /require\(["']rails\/all["']\)\n/
|
169
|
+
end
|
166
170
|
end
|
167
171
|
|
168
172
|
def master_key
|
@@ -262,7 +266,7 @@ module Rails
|
|
262
266
|
class_option :api, type: :boolean, desc: "Preconfigure smaller stack for API only apps"
|
263
267
|
class_option :minimal, type: :boolean, desc: "Preconfigure a minimal rails app"
|
264
268
|
class_option :javascript, type: :string, aliases: "-j", default: "importmap", desc: "Choose JavaScript approach [options: importmap (default), webpack, esbuild, rollup]"
|
265
|
-
class_option :css, type: :string, desc: "Choose CSS processor [options: tailwind, postcss, sass]"
|
269
|
+
class_option :css, type: :string, aliases: "-c", desc: "Choose CSS processor [options: tailwind, bootstrap, bulma, postcss, sass... check https://github.com/rails/cssbundling-rails]"
|
266
270
|
class_option :skip_bundle, type: :boolean, aliases: "-B", default: false, desc: "Don't run bundle install"
|
267
271
|
|
268
272
|
def initialize(*args)
|
@@ -275,7 +279,7 @@ module Rails
|
|
275
279
|
# Force sprockets and JavaScript to be skipped when generating API only apps.
|
276
280
|
# Can't modify options hash as it's frozen by default.
|
277
281
|
if options[:api]
|
278
|
-
self.options = options.merge(
|
282
|
+
self.options = options.merge(skip_asset_pipeline: true, skip_javascript: true).freeze
|
279
283
|
end
|
280
284
|
|
281
285
|
if options[:minimal]
|
@@ -440,10 +444,12 @@ module Rails
|
|
440
444
|
end
|
441
445
|
|
442
446
|
def delete_assets_initializer_skipping_sprockets
|
443
|
-
if
|
447
|
+
if skip_sprockets?
|
444
448
|
remove_file "config/initializers/assets.rb"
|
445
449
|
remove_file "app/assets/config/manifest.js"
|
450
|
+
remove_dir "app/assets/config"
|
446
451
|
remove_file "app/assets/stylesheets/application.css"
|
452
|
+
create_file "app/assets/stylesheets/application.css", "/* Application styles */\n" unless options[:api]
|
447
453
|
end
|
448
454
|
end
|
449
455
|
|