railties 7.0.0.alpha2 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -1
  3. data/lib/rails/all.rb +0 -1
  4. data/lib/rails/app_updater.rb +1 -1
  5. data/lib/rails/application/bootstrap.rb +6 -2
  6. data/lib/rails/application/configuration.rb +26 -9
  7. data/lib/rails/application/default_middleware_stack.rb +2 -1
  8. data/lib/rails/application/finisher.rb +2 -3
  9. data/lib/rails/commands/dbconsole/dbconsole_command.rb +0 -5
  10. data/lib/rails/engine/configuration.rb +1 -1
  11. data/lib/rails/engine.rb +3 -5
  12. data/lib/rails/gem_version.rb +1 -1
  13. data/lib/rails/generators/app_base.rb +88 -28
  14. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +1 -1
  15. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +8 -8
  16. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +2 -2
  17. data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +9 -4
  18. data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +1 -1
  19. data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +4 -7
  20. data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +4 -4
  21. data/lib/rails/generators/generated_attribute.rb +5 -5
  22. data/lib/rails/generators/named_base.rb +10 -10
  23. data/lib/rails/generators/rails/app/app_generator.rb +13 -6
  24. data/lib/rails/generators/rails/app/templates/Gemfile.tt +21 -20
  25. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +1 -0
  26. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +0 -1
  27. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +4 -1
  28. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +2 -23
  29. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +4 -4
  30. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +19 -20
  31. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +36 -4
  32. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +2 -2
  33. data/lib/rails/generators/rails/app/templates/gitignore.tt +3 -0
  34. data/lib/rails/generators/rails/plugin/plugin_generator.rb +9 -17
  35. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +4 -2
  36. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +5 -14
  37. data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +1 -1
  38. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +0 -1
  39. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +0 -5
  40. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +5 -5
  41. data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +7 -9
  42. data/lib/rails/generators/testing/behaviour.rb +2 -2
  43. data/lib/rails/railtie.rb +18 -1
  44. data/lib/rails/tasks/yarn.rake +4 -9
  45. data/lib/rails/templates/rails/mailers/email.html.erb +1 -1
  46. data/lib/rails/templates/rails/welcome/index.html.erb +60 -48
  47. data/lib/rails/test_unit/runner.rb +9 -4
  48. data/lib/rails/welcome_controller.rb +1 -0
  49. data/lib/rails.rb +4 -0
  50. metadata +19 -21
  51. data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +0 -8
  52. data/lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb.tt +0 -4
  53. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +0 -16
@@ -1,20 +1,17 @@
1
- <div id="<%%= dom_id <%= singular_table_name %> %>" class="scaffold_record">
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 <%= singular_table_name %>.<%= attribute.column_name %>.filename, <%= singular_table_name %>.<%= attribute.column_name %> if <%= singular_table_name %>.<%= attribute.column_name %>.attached? %>
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
- <%% <%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
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
- <%%= <%= singular_table_name %>.<%= attribute.column_name %> %>
12
+ <%%= <%= singular_name %>.<%= attribute.column_name %> %>
13
13
  <% end -%>
14
14
  </p>
15
15
 
16
16
  <% end -%>
17
- <p>
18
- <%%= link_to "Show this <%= human_name.downcase %>", <%= singular_table_name %> %>
19
- </p>
20
17
  </div>
@@ -1,10 +1,10 @@
1
- <p id="notice"><%%= notice %></p>
1
+ <p style="color: green"><%%= notice %></p>
2
2
 
3
3
  <%%= render @<%= singular_table_name %> %>
4
4
 
5
5
  <div>
6
- <%%= link_to "Edit this <%= human_name.downcase %>", edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
7
- <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path %>
6
+ <%%= link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %> %> |
7
+ <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
8
8
 
9
- <%%= button_to "Destroy this <%= human_name.downcase %>", <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete %>
9
+ <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete %>
10
10
  </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 :time_select
110
- when :datetime, :timestamp then :datetime_select
111
- when :date then :date_select
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.to_s(:db)
127
- when :date then Date.today.to_s(:db)
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
@@ -94,20 +94,20 @@ module Rails
94
94
  singular_name == plural_name
95
95
  end
96
96
 
97
- def index_helper # :doc:
98
- uncountable? ? "#{plural_route_name}_index" : plural_route_name
97
+ def index_helper(type: nil) # :doc:
98
+ [plural_route_name, ("index" if uncountable?), type].compact.join("_")
99
99
  end
100
100
 
101
- def show_helper # :doc:
102
- "#{singular_route_name}_url(@#{singular_table_name})"
101
+ def show_helper(arg = "@#{singular_table_name}", type: :url) # :doc:
102
+ "#{singular_route_name}_#{type}(#{arg})"
103
103
  end
104
104
 
105
- def edit_helper # :doc:
106
- "edit_#{show_helper}"
105
+ def edit_helper(...) # :doc:
106
+ "edit_#{show_helper(...)}"
107
107
  end
108
108
 
109
- def new_helper # :doc:
110
- "new_#{singular_route_name}_url"
109
+ def new_helper(type: :url) # :doc:
110
+ "new_#{singular_route_name}_#{type}"
111
111
  end
112
112
 
113
113
  def singular_table_name # :doc:
@@ -147,8 +147,8 @@ module Rails
147
147
  model_resource_name(prefix: "@")
148
148
  end
149
149
 
150
- def model_resource_name(prefix: "") # :doc:
151
- resource_name = "#{prefix}#{singular_table_name}"
150
+ def model_resource_name(base_name = singular_table_name, prefix: "") # :doc:
151
+ resource_name = "#{prefix}#{base_name}"
152
152
  if options[:model_name]
153
153
  "[#{controller_class_path.map { |name| ":" + name }.join(", ")}, #{resource_name}]"
154
154
  else
@@ -138,15 +138,15 @@ module Rails
138
138
  template "config/storage.yml"
139
139
  end
140
140
 
141
- if options[:skip_sprockets] && !assets_config_exist
141
+ if skip_sprockets? && !assets_config_exist
142
142
  remove_file "config/initializers/assets.rb"
143
143
  end
144
144
 
145
- if options[:skip_sprockets] && !asset_manifest_exist
145
+ if skip_sprockets? && !asset_manifest_exist
146
146
  remove_file "app/assets/config/manifest.js"
147
147
  end
148
148
 
149
- if options[:skip_sprockets] && !asset_app_stylesheet_exist
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(skip_sprockets: true, skip_javascript: true).freeze
282
+ self.options = options.merge(skip_asset_pipeline: true, skip_javascript: true).freeze
279
283
  end
280
284
 
281
285
  if options[:minimal]
@@ -299,6 +303,7 @@ module Rails
299
303
 
300
304
  public_task :set_default_accessors!
301
305
  public_task :create_root
306
+ public_task :target_rails_prerelease
302
307
 
303
308
  def create_root_files
304
309
  build(:readme)
@@ -440,10 +445,12 @@ module Rails
440
445
  end
441
446
 
442
447
  def delete_assets_initializer_skipping_sprockets
443
- if options[:skip_sprockets]
448
+ if skip_sprockets?
444
449
  remove_file "config/initializers/assets.rb"
445
450
  remove_file "app/assets/config/manifest.js"
451
+ remove_dir "app/assets/config"
446
452
  remove_file "app/assets/stylesheets/application.css"
453
+ create_file "app/assets/stylesheets/application.css", "/* Application styles */\n" unless options[:api]
447
454
  end
448
455
  end
449
456
 
@@ -2,29 +2,30 @@ source "https://rubygems.org"
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
4
  ruby <%= "\"#{RUBY_VERSION}\"" -%>
5
- <% gemfile_entries.each do |gem| -%>
6
- <% if gem.comment %>
7
5
 
8
- # <%= gem.comment %>
6
+ <% gemfile_entries.each do |gemfile_entry| %>
7
+ <%= gemfile_entry %>
8
+ <% end -%>
9
+ <% unless options.minimal? -%>
10
+
11
+ # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
12
+ # gem "kredis"
13
+
14
+ # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
15
+ # gem "bcrypt", "~> 3.1.7"
9
16
  <% end -%>
10
- <%= gem.commented_out ? "# " : "" %>gem "<%= gem.name %>"<%= %(, "#{gem.version}") if gem.version -%>
11
- <% if gem.options.any? -%>, <%= gem.options.map { |k,v| "#{k}: #{v.inspect}" }.join(", ") %><% end -%>
12
- <% end %>
13
17
 
14
18
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
15
19
  gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
16
-
17
20
  <% if depend_on_bootsnap? -%>
18
- # Reduces boot times through caching; required in config/boot.rb
19
- gem "bootsnap", ">= 1.4.4", require: false
20
21
 
21
- <%- end -%>
22
- # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
23
- # gem "bcrypt", "~> 3.1.7"
24
- <% unless options.skip_sprockets? || options.minimal? -%>
22
+ # Reduces boot times through caching; required in config/boot.rb
23
+ gem "bootsnap", require: false
24
+ <% end -%>
25
+ <% unless skip_sprockets? || options.minimal? -%>
25
26
 
26
27
  # Use Sass to process CSS
27
- # gem "sassc-rails", "~> 2.1"
28
+ # gem "sassc-rails"
28
29
  <% end -%>
29
30
  <% unless skip_active_storage? -%>
30
31
 
@@ -39,18 +40,18 @@ gem "bootsnap", ">= 1.4.4", require: false
39
40
  <% if RUBY_ENGINE == "ruby" -%>
40
41
 
41
42
  group :development, :test do
42
- # Start debugger with binding.b [https://github.com/ruby/debug]
43
- gem "debug", ">= 1.0.0", platforms: %i[ mri mingw x64_mingw ]
43
+ # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
44
+ gem "debug", platforms: %i[ mri mingw x64_mingw ]
44
45
  end
45
46
  <% end -%>
46
47
 
47
48
  group :development do
48
49
  <%- unless options.api? || options.skip_dev_gems? -%>
49
50
  # Use console on exceptions pages [https://github.com/rails/web-console]
50
- gem "web-console", ">= 4.1.0"
51
+ gem "web-console"
51
52
 
52
53
  # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
53
- # gem "rack-mini-profiler", ">= 2.3.3"
54
+ # gem "rack-mini-profiler"
54
55
 
55
56
  <%- end -%>
56
57
  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
@@ -60,8 +61,8 @@ end
60
61
  <%- if depends_on_system_test? -%>
61
62
  group :test do
62
63
  # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
63
- gem "capybara", ">= 3.26"
64
+ gem "capybara"
64
65
  gem "selenium-webdriver"
65
66
  gem "webdrivers"
66
67
  end
67
- <%- end -%>
68
+ <%- end -%>
@@ -2,6 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title><%= camelized %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
5
6
  <%%= csrf_meta_tags %>
6
7
  <%%= csp_meta_tag %>
7
8
 
@@ -15,7 +15,6 @@ require "action_controller/railtie"
15
15
  <%= comment_if :skip_action_text %>require "action_text/engine"
16
16
  require "action_view/railtie"
17
17
  <%= comment_if :skip_action_cable %>require "action_cable/engine"
18
- <%= comment_if :skip_sprockets %>require "sprockets/railtie"
19
18
  <%= comment_if :skip_test %>require "rails/test_unit/railtie"
20
19
  <% end -%>
21
20
 
@@ -14,6 +14,9 @@ Rails.application.configure do
14
14
  # Show full error reports.
15
15
  config.consider_all_requests_local = true
16
16
 
17
+ # Enable server timing
18
+ config.server_timing = true
19
+
17
20
  # Enable/disable caching. By default caching is disabled.
18
21
  # Run rails dev:cache to toggle caching.
19
22
  if Rails.root.join("tmp/caching-dev.txt").exist?
@@ -61,7 +64,7 @@ Rails.application.configure do
61
64
  config.active_record.verbose_query_logs = true
62
65
 
63
66
  <%- end -%>
64
- <%- unless options.skip_sprockets? -%>
67
+ <%- unless skip_sprockets? -%>
65
68
  # Suppress logger output for asset requests.
66
69
  config.assets.quiet = true
67
70
  <%- end -%>
@@ -26,7 +26,7 @@ Rails.application.configure do
26
26
  # Apache or NGINX already handles this.
27
27
  config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
28
28
 
29
- <%- unless options.skip_sprockets? -%>
29
+ <%- unless skip_sprockets? -%>
30
30
  # Compress CSS using a preprocessor.
31
31
  # config.assets.css_compressor = :sass
32
32
 
@@ -70,8 +70,8 @@ Rails.application.configure do
70
70
  # Use a real queuing backend for Active Job (and separate queues per environment).
71
71
  # config.active_job.queue_adapter = :resque
72
72
  # config.active_job.queue_name_prefix = "<%= app_name %>_production"
73
- <%- end -%>
74
73
 
74
+ <%- end -%>
75
75
  <%- unless options.skip_action_mailer? -%>
76
76
  config.action_mailer.perform_caching = false
77
77
 
@@ -104,25 +104,4 @@ Rails.application.configure do
104
104
  # Do not dump schema after migrations.
105
105
  config.active_record.dump_schema_after_migration = false
106
106
  <%- end -%>
107
-
108
- # Inserts middleware to perform automatic connection switching.
109
- # The `database_selector` hash is used to pass options to the DatabaseSelector
110
- # middleware. The `delay` is used to determine how long to wait after a write
111
- # to send a subsequent read to the primary.
112
- #
113
- # The `database_resolver` class is used by the middleware to determine which
114
- # database is appropriate to use based on the time delay.
115
- #
116
- # The `database_resolver_context` class is used by the middleware to set
117
- # timestamps for the last write to the primary. The resolver uses the context
118
- # class timestamps to determine how long to wait before reading from the
119
- # replica.
120
- #
121
- # By default Rails will store a last write timestamp in the session. The
122
- # DatabaseSelector middleware is designed as such you can define your own
123
- # strategy for connection switching and pass that into the middleware through
124
- # these configuration options.
125
- # config.active_record.database_selector = { delay: 2.seconds }
126
- # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
127
- # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
128
107
  end
@@ -11,10 +11,10 @@ Rails.application.configure do
11
11
  # Turn false under Spring and add config.action_view.cache_template_loading = true
12
12
  config.cache_classes = true
13
13
 
14
- # Do not eager load code on boot. This avoids loading your whole application
15
- # just for the purpose of running a single test. If you are using a tool that
16
- # preloads Rails for running tests, you may have to set it to true.
17
- config.eager_load = false
14
+ # Eager loading loads your whole application. When running a single test locally,
15
+ # this probably isn't necessary. It's a good idea to do in a continuous integration
16
+ # system, or in some way before deploying your code.
17
+ config.eager_load = ENV["CI"].present?
18
18
 
19
19
  # Configure public file server for tests with Cache-Control for performance.
20
20
  config.public_file_server.enabled = true
@@ -4,24 +4,23 @@
4
4
  # For further information see the following documentation
5
5
  # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
6
6
 
7
- # Rails.application.config.content_security_policy do |policy|
8
- # policy.default_src :self, :https
9
- # policy.font_src :self, :https, :data
10
- # policy.img_src :self, :https, :data
11
- # policy.object_src :none
12
- # policy.script_src :self, :https
13
- # policy.style_src :self, :https
14
- # # Specify URI for violation reports
15
- # # policy.report_uri "/csp-violation-report-endpoint"
7
+ # Rails.application.configure do
8
+ # config.content_security_policy do |policy|
9
+ # policy.default_src :self, :https
10
+ # policy.font_src :self, :https, :data
11
+ # policy.img_src :self, :https, :data
12
+ # policy.object_src :none
13
+ # policy.script_src :self, :https
14
+ # policy.style_src :self, :https
15
+ # # Specify URI for violation reports
16
+ # # policy.report_uri "/csp-violation-report-endpoint"
17
+ # end
18
+ #
19
+ # # Generate session nonces for permitted importmap and inline scripts
20
+ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21
+ # config.content_security_policy_nonce_directives = %w(script-src)
22
+ #
23
+ # # Report CSP violations to a specified URI. See:
24
+ # # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
25
+ # # config.content_security_policy_report_only = true
16
26
  # end
17
-
18
- # If you are using UJS then enable automatic nonce generation
19
- # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
20
-
21
- # Set the nonce only to specific directives
22
- # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
23
-
24
- # Report CSP violations to a specified URI
25
- # For further information see the following documentation:
26
- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
27
- # Rails.application.config.content_security_policy_report_only = true
@@ -9,10 +9,6 @@
9
9
  # Read the Guide for Upgrading Ruby on Rails for more info on each option.
10
10
  # https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
11
11
 
12
- # Raise an error when trying to use forgery protection without a working
13
- # session.
14
- # Rails.application.config.action_controller.silence_disabled_session_errors = false
15
-
16
12
  # `button_to` view helper will render `<button>` element, regardless of whether
17
13
  # or not the content is passed as the first argument or as a block.
18
14
  # Rails.application.config.action_view.button_to_generates_button_tag = true
@@ -45,6 +41,17 @@
45
41
  # and you have no plans to rollback.
46
42
  # Rails.application.config.active_support.cache_format_version = 7.0
47
43
 
44
+ # Calls `Rails.application.executor.wrap` around test cases.
45
+ # This makes test cases behave closer to an actual request or job.
46
+ # Several features that are normally disabled in test, such as Active Record query cache
47
+ # and asynchronous queries will then be enabled.
48
+ # Rails.application.config.active_support.executor_around_test_case = true
49
+
50
+ # Define the isolation level of most of Rails internal state.
51
+ # If you use a fiber based server or job processor, you should set it to `:fiber`.
52
+ # Otherwise the default of `:thread` if preferable.
53
+ # Rails.application.config.active_support.isolation_level = :thread
54
+
48
55
  # Set both the `:open_timeout` and `:read_timeout` values for `:smtp` delivery method.
49
56
  # Rails.application.config.action_mailer.smtp_timeout = 5
50
57
 
@@ -54,6 +61,9 @@
54
61
  # Rails.application.config.active_storage.video_preview_arguments =
55
62
  # "-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"
56
63
 
64
+ # Automatically infer `inverse_of` for associations with a scope.
65
+ # Rails.application.config.active_record.automatic_scope_inversing = true
66
+
57
67
  # Raise when running tests if fixtures contained foreign key violations
58
68
  # Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
59
69
 
@@ -83,3 +93,25 @@
83
93
  #
84
94
  # See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
85
95
  # Rails.application.config.action_dispatch.cookies_serializer = :hybrid
96
+
97
+ # Enable parameter wrapping for JSON.
98
+ # Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.
99
+ # To disable parameter wrapping entirely, set this config to `false`.
100
+ # Rails.application.config.action_controller.wrap_parameters_by_default = true
101
+
102
+ # Specifies whether generated namespaced UUIDs follow the RFC 4122 standard for namespace IDs provided as a
103
+ # `String` to `Digest::UUID.uuid_v3` or `Digest::UUID.uuid_v5` method calls.
104
+ #
105
+ # See https://guides.rubyonrails.org/configuring.html#config-active-support-use-rfc4122-namespaced-uuids for
106
+ # more information.
107
+ # Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true
108
+
109
+ # Change the default headers to disable browsers' flawed legacy XSS protection.
110
+ # Rails.application.config.action_dispatch.default_headers = {
111
+ # "X-Frame-Options" => "SAMEORIGIN",
112
+ # "X-XSS-Protection" => "0",
113
+ # "X-Content-Type-Options" => "nosniff",
114
+ # "X-Download-Options" => "noopen",
115
+ # "X-Permitted-Cross-Domain-Policies" => "none",
116
+ # "Referrer-Policy" => "strict-origin-when-cross-origin"
117
+ # }
@@ -1,6 +1,6 @@
1
1
  Rails.application.routes.draw do
2
- # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
2
+ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
3
3
 
4
- # Almost every application defines a route for the root path ("/") at the top of this file.
4
+ # Defines the root path route ("/")
5
5
  # root "articles#index"
6
6
  end
@@ -31,6 +31,9 @@
31
31
  /storage/*
32
32
  <% if keeps? -%>
33
33
  !/storage/.keep
34
+ /tmp/storage/*
35
+ !/tmp/storage/
36
+ !/tmp/storage/.keep
34
37
  <% end -%>
35
38
  <% end -%>
36
39
  <% unless options.api? -%>
@@ -94,10 +94,6 @@ module Rails
94
94
  def test
95
95
  template "test/test_helper.rb"
96
96
  template "test/%namespaced_name%_test.rb"
97
- append_file "Rakefile", <<~EOF
98
- #{rakefile_test_tasks}
99
- task default: :test
100
- EOF
101
97
 
102
98
  if engine?
103
99
  empty_directory_with_keep_file "test/fixtures/files"
@@ -235,6 +231,10 @@ module Rails
235
231
  public_task :set_default_accessors!
236
232
  public_task :create_root
237
233
 
234
+ def target_rails_prerelease
235
+ super("plugin new")
236
+ end
237
+
238
238
  def create_root_files
239
239
  build(:readme)
240
240
  build(:rakefile)
@@ -316,7 +316,7 @@ module Rails
316
316
  mute do
317
317
  build(:generate_test_dummy)
318
318
  build(:test_dummy_config)
319
- build(:test_dummy_sprocket_assets) unless options[:skip_sprockets]
319
+ build(:test_dummy_sprocket_assets) unless skip_sprockets?
320
320
  build(:test_dummy_clean)
321
321
  # ensure that bin/rails has proper dummy_path
322
322
  build(:bin, true)
@@ -398,6 +398,10 @@ module Rails
398
398
  end
399
399
  end
400
400
 
401
+ def rails_version_specifier(gem_version = Rails.gem_version)
402
+ [">= #{gem_version}"]
403
+ end
404
+
401
405
  def valid_const?
402
406
  if /-\d/.match?(original_name)
403
407
  raise Error, "Invalid plugin name #{original_name}. Please give a name which does not contain a namespace starting with numeric characters."
@@ -418,18 +422,6 @@ module Rails
418
422
  defined?(::PluginBuilder) ? ::PluginBuilder : Rails::PluginBuilder
419
423
  end
420
424
 
421
- def rakefile_test_tasks
422
- <<-RUBY
423
- require "rake/testtask"
424
-
425
- Rake::TestTask.new(:test) do |t|
426
- t.libs << "test"
427
- t.pattern = "test/**/*_test.rb"
428
- t.verbose = false
429
- end
430
- RUBY
431
- end
432
-
433
425
  def dummy_path(path = nil)
434
426
  @dummy_path = path if path
435
427
  @dummy_path || options[:dummy_path]
@@ -20,7 +20,9 @@ Gem::Specification.new do |spec|
20
20
  spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
21
21
  spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
22
 
23
- spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
25
+ end
24
26
 
25
- <%= "# " if options.dev? || options.edge? || options.main? -%>spec.add_dependency "rails", "<%= Array(rails_version_specifier).join('", "') %>"
27
+ <%= "# " if rails_prerelease? -%>spec.add_dependency "rails", "<%= Array(rails_version_specifier).join('", "') %>"
26
28
  end
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
4
  <% if options[:skip_gemspec] -%>
5
- <%= "# " if options.dev? || options.edge? || options.main? -%>gem "rails", "<%= Array(rails_version_specifier).join("', '") %>"
5
+ <%= "# " if rails_prerelease? -%>gem "rails", "<%= Array(rails_version_specifier).join("', '") %>"
6
6
  <% else -%>
7
7
  # Specify your gem's dependencies in <%= name %>.gemspec.
8
8
  gemspec
@@ -14,20 +14,11 @@ group :development do
14
14
  end
15
15
  <% end -%>
16
16
 
17
- <% if options.dev? || options.edge? -%>
18
- # Your gem is dependent on dev or edge Rails. Once you can lock this
17
+ <% if rails_prerelease? -%>
18
+ # Your gem is dependent on a prerelease version of Rails. Once you can lock this
19
19
  # dependency down to a specific version, move it to your gemspec.
20
- <% max_width = gemfile_entries.map { |g| g.name.length }.max -%>
21
- <% gemfile_entries.each do |gem| -%>
22
- <% if gem.comment -%>
23
-
24
- # <%= gem.comment %>
25
- <% end -%>
26
- <%= gem.commented_out ? "# " : "" %>gem "<%= gem.name %>"<%= %(, "#{gem.version}") if gem.version -%>
27
- <% if gem.options.any? -%>
28
- , <%= gem.options.map { |k,v|
29
- "#{k}: #{v.inspect}" }.join(", ") %>
30
- <% end -%>
20
+ <% gemfile_entries.each do |gemfile_entry| -%>
21
+ <%= gemfile_entry %>
31
22
  <% end -%>
32
23
 
33
24
  <% end -%>
@@ -1,6 +1,6 @@
1
1
  <%= wrap_in_modules <<~rb
2
2
  class ApplicationRecord < ActiveRecord::Base
3
- primary_abstract_class
3
+ self.abstract_class = true
4
4
  end
5
5
  rb
6
6
  %>
@@ -24,7 +24,6 @@ require "action_controller/railtie"
24
24
  <%= comment_if :skip_action_mailer %>require "action_mailer/railtie"
25
25
  require "action_view/railtie"
26
26
  <%= comment_if :skip_action_cable %>require "action_cable/engine"
27
- <%= comment_if :skip_sprockets %>require "sprockets/railtie"
28
27
  <%= comment_if :skip_test %>require "rails/test_unit/railtie"
29
28
  <% end -%>
30
29
  require "rails/engine/commands"
@@ -10,11 +10,6 @@ ActiveRecord::Migrator.migrations_paths << File.expand_path("../db/migrate", __d
10
10
  <% end -%>
11
11
  require "rails/test_help"
12
12
 
13
- <% unless engine? -%>
14
- require "rails/test_unit/reporter"
15
- Rails::TestUnitReporter.executable = "bin/test"
16
- <% end -%>
17
-
18
13
  <% unless options[:skip_active_record] -%>
19
14
  # Load fixtures from the engine
20
15
  if ActiveSupport::TestCase.respond_to?(:fixture_path=)