railties 6.1.7.8 → 7.0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +219 -320
  3. data/RDOC_MAIN.rdoc +16 -16
  4. data/README.rdoc +1 -2
  5. data/lib/minitest/rails_plugin.rb +1 -1
  6. data/lib/rails/all.rb +0 -1
  7. data/lib/rails/app_updater.rb +9 -6
  8. data/lib/rails/application/bootstrap.rb +24 -5
  9. data/lib/rails/application/configuration.rb +95 -33
  10. data/lib/rails/application/default_middleware_stack.rb +22 -3
  11. data/lib/rails/application/finisher.rb +53 -95
  12. data/lib/rails/application/routes_reloader.rb +8 -0
  13. data/lib/rails/application.rb +74 -101
  14. data/lib/rails/application_controller.rb +3 -3
  15. data/lib/rails/autoloaders/inflector.rb +21 -0
  16. data/lib/rails/autoloaders.rb +42 -42
  17. data/lib/rails/code_statistics.rb +2 -2
  18. data/lib/rails/code_statistics_calculator.rb +10 -1
  19. data/lib/rails/command/base.rb +26 -12
  20. data/lib/rails/command/behavior.rb +1 -1
  21. data/lib/rails/command/environment_argument.rb +1 -1
  22. data/lib/rails/command.rb +9 -6
  23. data/lib/rails/commands/console/console_command.rb +4 -0
  24. data/lib/rails/commands/credentials/USAGE +4 -2
  25. data/lib/rails/commands/credentials/credentials_command/diffing.rb +26 -16
  26. data/lib/rails/commands/credentials/credentials_command.rb +7 -3
  27. data/lib/rails/commands/dbconsole/dbconsole_command.rb +10 -11
  28. data/lib/rails/commands/help/USAGE +3 -2
  29. data/lib/rails/commands/runner/runner_command.rb +3 -2
  30. data/lib/rails/commands/server/server_command.rb +7 -5
  31. data/lib/rails/configuration.rb +18 -23
  32. data/lib/rails/console/helpers.rb +2 -2
  33. data/lib/rails/engine/configuration.rb +3 -3
  34. data/lib/rails/engine.rb +31 -37
  35. data/lib/rails/gem_version.rb +5 -5
  36. data/lib/rails/generators/actions/create_migration.rb +2 -4
  37. data/lib/rails/generators/actions.rb +229 -62
  38. data/lib/rails/generators/app_base.rb +155 -130
  39. data/lib/rails/generators/app_name.rb +1 -1
  40. data/lib/rails/generators/base.rb +12 -16
  41. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +2 -0
  42. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +8 -8
  43. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +8 -4
  44. data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +11 -28
  45. data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +7 -3
  46. data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +17 -0
  47. data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +8 -17
  48. data/lib/rails/generators/erb.rb +1 -1
  49. data/lib/rails/generators/generated_attribute.rb +45 -9
  50. data/lib/rails/generators/migration.rb +2 -6
  51. data/lib/rails/generators/model_helpers.rb +1 -1
  52. data/lib/rails/generators/named_base.rb +13 -13
  53. data/lib/rails/generators/rails/app/app_generator.rb +70 -91
  54. data/lib/rails/generators/rails/app/templates/Gemfile.tt +44 -52
  55. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +2 -2
  56. data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb.tt +2 -2
  57. data/lib/rails/generators/rails/app/templates/app/models/application_record.rb.tt +1 -1
  58. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +3 -9
  59. data/lib/rails/generators/rails/app/templates/bin/rails.tt +1 -4
  60. data/lib/rails/generators/rails/app/templates/bin/rake.tt +0 -3
  61. data/lib/rails/generators/rails/app/templates/bin/setup.tt +9 -14
  62. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +0 -1
  63. data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +1 -1
  64. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +2 -2
  65. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +3 -3
  66. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +3 -3
  67. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +2 -2
  68. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +3 -3
  69. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +2 -2
  70. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +3 -3
  71. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +1 -1
  72. data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +5 -5
  73. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +7 -13
  74. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +12 -39
  75. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +7 -12
  76. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +1 -5
  77. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +21 -28
  78. data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +2 -2
  79. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +3 -1
  80. data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb.tt +4 -4
  81. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +143 -0
  82. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +3 -3
  83. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +1 -1
  84. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +4 -1
  85. data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +5 -5
  86. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +2 -2
  87. data/lib/rails/generators/rails/app/templates/gitattributes.tt +0 -5
  88. data/lib/rails/generators/rails/app/templates/gitignore.tt +3 -1
  89. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +1 -1
  90. data/lib/rails/generators/rails/controller/controller_generator.rb +1 -2
  91. data/lib/rails/generators/rails/controller/templates/controller.rb.tt +0 -4
  92. data/lib/rails/generators/rails/db/system/change/change_generator.rb +1 -1
  93. data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -1
  94. data/lib/rails/generators/rails/plugin/plugin_generator.rb +76 -27
  95. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +7 -3
  96. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +9 -31
  97. data/lib/rails/generators/rails/plugin/templates/README.md.tt +1 -1
  98. data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +2 -2
  99. data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +0 -3
  100. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +7 -6
  101. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +0 -5
  102. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +2 -2
  103. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb.tt +1 -1
  104. data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +2 -2
  105. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +2 -7
  106. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +0 -19
  107. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +1 -5
  108. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +6 -10
  109. data/lib/rails/generators/resource_helpers.rb +2 -2
  110. data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +1 -1
  111. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +2 -2
  112. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +3 -3
  113. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +5 -5
  114. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +7 -7
  115. data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +9 -11
  116. data/lib/rails/generators/testing/behaviour.rb +3 -4
  117. data/lib/rails/generators.rb +17 -24
  118. data/lib/rails/info.rb +1 -1
  119. data/lib/rails/info_controller.rb +1 -3
  120. data/lib/rails/initializable.rb +1 -1
  121. data/lib/rails/mailers_controller.rb +2 -4
  122. data/lib/rails/paths.rb +1 -1
  123. data/lib/rails/rack/logger.rb +7 -9
  124. data/lib/rails/railtie/configuration.rb +1 -2
  125. data/lib/rails/railtie.rb +36 -13
  126. data/lib/rails/ruby_version_check.rb +3 -3
  127. data/lib/rails/source_annotation_extractor.rb +1 -1
  128. data/lib/rails/tasks/framework.rake +7 -9
  129. data/lib/rails/tasks/statistics.rake +3 -1
  130. data/lib/rails/tasks/tmp.rake +8 -1
  131. data/lib/rails/tasks/yarn.rake +8 -9
  132. data/lib/rails/tasks/zeitwerk.rake +2 -10
  133. data/lib/rails/templates/layouts/application.html.erb +15 -0
  134. data/lib/rails/templates/rails/mailers/email.html.erb +13 -11
  135. data/lib/rails/templates/rails/welcome/index.html.erb +64 -48
  136. data/lib/rails/test_help.rb +4 -0
  137. data/lib/rails/test_unit/railtie.rb +0 -4
  138. data/lib/rails/test_unit/runner.rb +16 -9
  139. data/lib/rails/test_unit/testing.rake +4 -9
  140. data/lib/rails/version.rb +1 -1
  141. data/lib/rails/welcome_controller.rb +1 -0
  142. data/lib/rails.rb +13 -2
  143. metadata +33 -37
  144. data/lib/rails/command/spellchecker.rb +0 -57
  145. data/lib/rails/generators/css/assets/assets_generator.rb +0 -15
  146. data/lib/rails/generators/css/assets/templates/stylesheet.css +0 -4
  147. data/lib/rails/generators/css/scaffold/scaffold_generator.rb +0 -18
  148. data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +0 -6
  149. data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +0 -5
  150. data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +0 -23
  151. data/lib/rails/generators/rails/app/templates/bin/spring.tt +0 -13
  152. data/lib/rails/generators/rails/app/templates/bin/yarn.tt +0 -16
  153. data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb.tt +0 -8
  154. data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +0 -8
  155. data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb.tt +0 -5
  156. data/lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb.tt +0 -4
  157. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_1.rb.tt +0 -67
  158. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +0 -16
  159. data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +0 -6
  160. data/lib/rails/generators/rails/app/templates/package.json.tt +0 -11
  161. data/lib/rails/generators/rails/assets/USAGE +0 -16
  162. data/lib/rails/generators/rails/assets/assets_generator.rb +0 -26
  163. data/lib/rails/generators/rails/assets/templates/stylesheet.css +0 -4
  164. data/lib/rails/generators/rails/scaffold/templates/scaffold.css +0 -80
@@ -1,14 +1,10 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # Version of your assets, change this if you want to expire all your assets.
4
- Rails.application.config.assets.version = '1.0'
4
+ Rails.application.config.assets.version = "1.0"
5
5
 
6
6
  # Add additional assets to the asset load path.
7
7
  # Rails.application.config.assets.paths << Emoji.images_path
8
- <%- unless options[:skip_javascript] -%>
9
- # Add Yarn node_modules folder to the asset load path.
10
- Rails.application.config.assets.paths << Rails.root.join('node_modules')
11
- <%- end -%>
12
8
 
13
9
  # Precompile additional assets.
14
10
  # application.js, application.css, and all non-JS/CSS in the app/assets
@@ -1,32 +1,25 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Define an application-wide content security policy
4
- # For further information see the following documentation
5
- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
3
+ # Define an application-wide content security policy.
4
+ # See the Securing Rails Applications Guide for more information:
5
+ # https://guides.rubyonrails.org/security.html#content-security-policy-header
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
- <%- unless options[:skip_javascript] -%>
15
- # # If you are using webpack-dev-server then specify webpack-dev-server host
16
- # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
17
- <%- end -%>
18
-
19
- # # Specify URI for violation reports
20
- # # 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 violations without enforcing the policy.
24
+ # # config.content_security_policy_report_only = true
21
25
  # end
22
-
23
- # If you are using UJS then enable automatic nonce generation
24
- # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
25
-
26
- # Set the nonce only to specific directives
27
- # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
28
-
29
- # Report CSP violations to a specified URI
30
- # For further information see the following documentation:
31
- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
32
- # Rails.application.config.content_security_policy_report_only = true
@@ -7,9 +7,9 @@
7
7
 
8
8
  # Rails.application.config.middleware.insert_before 0, Rack::Cors do
9
9
  # allow do
10
- # origins 'example.com'
10
+ # origins "example.com"
11
11
  #
12
- # resource '*',
12
+ # resource "*",
13
13
  # headers: :any,
14
14
  # methods: [:get, :post, :put, :patch, :delete, :options, :head]
15
15
  # end
@@ -1,6 +1,8 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Configure sensitive parameters which will be filtered from the log file.
3
+ # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4
+ # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5
+ # notations and behaviors.
4
6
  Rails.application.config.filter_parameters += [
5
7
  :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
6
8
  ]
@@ -4,13 +4,13 @@
4
4
  # are locale specific, and you may define rules for as many different
5
5
  # locales as you wish. All of these examples are active by default:
6
6
  # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
- # inflect.plural /^(ox)$/i, '\1en'
8
- # inflect.singular /^(ox)en/i, '\1'
9
- # inflect.irregular 'person', 'people'
7
+ # inflect.plural /^(ox)$/i, "\\1en"
8
+ # inflect.singular /^(ox)en/i, "\\1"
9
+ # inflect.irregular "person", "people"
10
10
  # inflect.uncountable %w( fish sheep )
11
11
  # end
12
12
 
13
13
  # These inflection rules are supported but not enabled by default:
14
14
  # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
- # inflect.acronym 'RESTful'
15
+ # inflect.acronym "RESTful"
16
16
  # end
@@ -0,0 +1,143 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file eases your Rails 7.0 framework defaults upgrade.
4
+ #
5
+ # Uncomment each configuration one by one to switch to the new default.
6
+ # Once your application is ready to run with all new defaults, you can remove
7
+ # this file and set the `config.load_defaults` to `7.0`.
8
+ #
9
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
10
+ # https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
11
+
12
+ # `button_to` view helper will render `<button>` element, regardless of whether
13
+ # or not the content is passed as the first argument or as a block.
14
+ # Rails.application.config.action_view.button_to_generates_button_tag = true
15
+
16
+ # `stylesheet_link_tag` view helper will not render the media attribute by default.
17
+ # Rails.application.config.action_view.apply_stylesheet_media_default = false
18
+
19
+ # Change the digest class for the key generators to `OpenSSL::Digest::SHA256`.
20
+ # Changing this default means invalidate all encrypted messages generated by
21
+ # your application and, all the encrypted cookies. Only change this after you
22
+ # rotated all the messages using the key rotator.
23
+ #
24
+ # See upgrading guide for more information on how to build a rotator.
25
+ # https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html
26
+ # Rails.application.config.active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
27
+
28
+ # Change the digest class for ActiveSupport::Digest.
29
+ # Changing this default means that for example Etags change and
30
+ # various cache keys leading to cache invalidation.
31
+ # Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256
32
+
33
+ # Don't override ActiveSupport::TimeWithZone.name and use the default Ruby
34
+ # implementation.
35
+ # Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true
36
+
37
+ # Calls `Rails.application.executor.wrap` around test cases.
38
+ # This makes test cases behave closer to an actual request or job.
39
+ # Several features that are normally disabled in test, such as Active Record query cache
40
+ # and asynchronous queries will then be enabled.
41
+ # Rails.application.config.active_support.executor_around_test_case = true
42
+
43
+ # Set both the `:open_timeout` and `:read_timeout` values for `:smtp` delivery method.
44
+ # Rails.application.config.action_mailer.smtp_timeout = 5
45
+
46
+ # The ActiveStorage video previewer will now use scene change detection to generate
47
+ # better preview images (rather than the previous default of using the first frame
48
+ # of the video).
49
+ # Rails.application.config.active_storage.video_preview_arguments =
50
+ # "-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"
51
+
52
+ # Automatically infer `inverse_of` for associations with a scope.
53
+ # Rails.application.config.active_record.automatic_scope_inversing = true
54
+
55
+ # Raise when running tests if fixtures contained foreign key violations
56
+ # Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
57
+
58
+ # Disable partial inserts.
59
+ # This default means that all columns will be referenced in INSERT queries
60
+ # regardless of whether they have a default or not.
61
+ # Rails.application.config.active_record.partial_inserts = false
62
+
63
+ # Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.
64
+ # Rails.application.config.action_controller.raise_on_open_redirects = true
65
+
66
+ # Change the variant processor for Active Storage.
67
+ # Changing this default means updating all places in your code that
68
+ # generate variants to use image processing macros and ruby-vips
69
+ # operations. See the upgrading guide for detail on the changes required.
70
+ # The `:mini_magick` option is not deprecated; it's fine to keep using it.
71
+ # Rails.application.config.active_storage.variant_processor = :vips
72
+
73
+ # Enable parameter wrapping for JSON.
74
+ # Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.
75
+ # To disable parameter wrapping entirely, set this config to `false`.
76
+ # Rails.application.config.action_controller.wrap_parameters_by_default = true
77
+
78
+ # Specifies whether generated namespaced UUIDs follow the RFC 4122 standard for namespace IDs provided as a
79
+ # `String` to `Digest::UUID.uuid_v3` or `Digest::UUID.uuid_v5` method calls.
80
+ #
81
+ # See https://guides.rubyonrails.org/configuring.html#config-active-support-use-rfc4122-namespaced-uuids for
82
+ # more information.
83
+ # Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true
84
+
85
+ # Change the default headers to disable browsers' flawed legacy XSS protection.
86
+ # Rails.application.config.action_dispatch.default_headers = {
87
+ # "X-Frame-Options" => "SAMEORIGIN",
88
+ # "X-XSS-Protection" => "0",
89
+ # "X-Content-Type-Options" => "nosniff",
90
+ # "X-Download-Options" => "noopen",
91
+ # "X-Permitted-Cross-Domain-Policies" => "none",
92
+ # "Referrer-Policy" => "strict-origin-when-cross-origin"
93
+ # }
94
+
95
+
96
+ # ** Please read carefully, this must be configured in config/application.rb **
97
+ # Change the format of the cache entry.
98
+ # Changing this default means that all new cache entries added to the cache
99
+ # will have a different format that is not supported by Rails 6.1 applications.
100
+ # Only change this value after your application is fully deployed to Rails 7.0
101
+ # and you have no plans to rollback.
102
+ # When you're ready to change format, add this to `config/application.rb` (NOT this file):
103
+ # config.active_support.cache_format_version = 7.0
104
+
105
+
106
+ # Cookie serializer: 2 options
107
+ #
108
+ # If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
109
+ # is `:marshal`. The default for new apps is `:json`.
110
+ #
111
+ # Rails.application.config.action_dispatch.cookies_serializer = :json
112
+ #
113
+ #
114
+ # To migrate an existing application to the `:json` serializer, use the `:hybrid` option.
115
+ #
116
+ # Rails transparently deserializes existing (Marshal-serialized) cookies on read and
117
+ # re-writes them in the JSON format.
118
+ #
119
+ # It is fine to use `:hybrid` long term; you should do that until you're confident *all* your cookies
120
+ # have been converted to JSON. To keep using `:hybrid` long term, move this config to its own
121
+ # initializer or to `config/application.rb`.
122
+ #
123
+ # Rails.application.config.action_dispatch.cookies_serializer = :hybrid
124
+ #
125
+ #
126
+ # If your cookies can't yet be serialized to JSON, keep using `:marshal` for backward-compatibility.
127
+ #
128
+ # If you have configured the serializer elsewhere, you can remove this section of the file.
129
+ #
130
+ # See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
131
+
132
+ # Change the return value of `ActionDispatch::Request#content_type` to the Content-Type header without modification.
133
+ # Rails.application.config.action_dispatch.return_only_request_media_type_on_content_type = false
134
+
135
+ # Active Storage `has_many_attached` relationships will default to replacing the current collection instead of appending to it.
136
+ # Thus, to support submitting an empty collection, the `file_field` helper will render an hidden field `include_hidden` by default when `multiple_file_field_include_hidden` is set to `true`.
137
+ # See https://guides.rubyonrails.org/configuring.html#config-active-storage-multiple-file-field-include-hidden for more information.
138
+ # Rails.application.config.active_storage.multiple_file_field_include_hidden = true
139
+
140
+ # ** Please read carefully, this must be configured in config/application.rb (NOT this file) **
141
+ # Disables the deprecated #to_s override in some Ruby core classes
142
+ # See https://guides.rubyonrails.org/configuring.html#config-active-support-disable-to-s-conversion for more information.
143
+ # config.active_support.disable_to_s_conversion = true
@@ -4,11 +4,11 @@
4
4
  #
5
5
  # To use the locales, use `I18n.t`:
6
6
  #
7
- # I18n.t 'hello'
7
+ # I18n.t "hello"
8
8
  #
9
9
  # In views, this is aliased to just `t`:
10
10
  #
11
- # <%= t('hello') %>
11
+ # <%= t("hello") %>
12
12
  #
13
13
  # To use a different locale, set it with `I18n.locale`:
14
14
  #
@@ -24,7 +24,7 @@
24
24
  # Instead, surround them with single quotes.
25
25
  #
26
26
  # en:
27
- # 'true': 'foo'
27
+ # "true": "foo"
28
28
  #
29
29
  # To learn more, please read the Rails Internationalization guide
30
30
  # available at https://guides.rubyonrails.org/i18n.html.
@@ -39,5 +39,5 @@ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
39
39
  #
40
40
  # preload_app!
41
41
 
42
- # Allow puma to be restarted by `rails restart` command.
42
+ # Allow puma to be restarted by `bin/rails restart` command.
43
43
  plugin :tmp_restart
@@ -1,3 +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
+
4
+ # Defines the root path route ("/")
5
+ # root "articles#index"
3
6
  end
@@ -6,27 +6,27 @@ local:
6
6
  service: Disk
7
7
  root: <%%= Rails.root.join("storage") %>
8
8
 
9
- # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
9
+ # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
10
  # amazon:
11
11
  # service: S3
12
12
  # access_key_id: <%%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
13
  # secret_access_key: <%%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
14
  # region: us-east-1
15
- # bucket: your_own_bucket
15
+ # bucket: your_own_bucket-<%%= Rails.env %>
16
16
 
17
17
  # Remember not to checkin your GCS keyfile to a repository
18
18
  # google:
19
19
  # service: GCS
20
20
  # project: your_project
21
21
  # credentials: <%%= Rails.root.join("path/to/gcs.keyfile") %>
22
- # bucket: your_own_bucket
22
+ # bucket: your_own_bucket-<%%= Rails.env %>
23
23
 
24
- # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
24
+ # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
25
  # microsoft:
26
26
  # service: AzureStorage
27
27
  # storage_account_name: your_account_name
28
28
  # storage_access_key: <%%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
- # container: your_container_name
29
+ # container: your_container_name-<%%= Rails.env %>
30
30
 
31
31
  # mirror:
32
32
  # service: Mirror
@@ -3,5 +3,5 @@
3
3
  #
4
4
  # Examples:
5
5
  #
6
- # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7
- # Character.create(name: 'Luke', movie: movies.first)
6
+ # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
7
+ # Character.create(name: "Luke", movie: movies.first)
@@ -5,10 +5,5 @@
5
5
  db/schema.rb linguist-generated
6
6
  <% end -%>
7
7
 
8
- <% unless options[:skip_javascript] -%>
9
- # Mark the yarn lockfile as having been generated.
10
- yarn.lock linguist-generated
11
- <% end -%>
12
-
13
8
  # Mark any vendored files as having been vendored.
14
9
  vendor/* linguist-vendored
@@ -31,10 +31,12 @@
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? -%>
37
40
 
38
41
  /public/assets
39
42
  <% end -%>
40
- .byebug_history
@@ -1,4 +1,4 @@
1
- ENV['RAILS_ENV'] ||= 'test'
1
+ ENV["RAILS_ENV"] ||= "test"
2
2
  require_relative "../config/environment"
3
3
  require "rails/test_help"
4
4
 
@@ -6,7 +6,6 @@ module Rails
6
6
  argument :actions, type: :array, default: [], banner: "action action"
7
7
  class_option :skip_routes, type: :boolean, desc: "Don't add routes to config/routes.rb."
8
8
  class_option :helper, type: :boolean
9
- class_option :assets, type: :boolean
10
9
 
11
10
  check_class_collision suffix: "Controller"
12
11
 
@@ -21,7 +20,7 @@ module Rails
21
20
  route routing_code, namespace: regular_class_path
22
21
  end
23
22
 
24
- hook_for :template_engine, :test_framework, :helper, :assets do |generator|
23
+ hook_for :template_engine, :test_framework, :helper do |generator|
25
24
  invoke generator, [ remove_possible_suffix(name), actions ]
26
25
  end
27
26
 
@@ -1,7 +1,3 @@
1
- <% if namespaced? -%>
2
- require_dependency "<%= namespaced_path %>/application_controller"
3
-
4
- <% end -%>
5
1
  <% module_namespacing do -%>
6
2
  class <%= class_name %>Controller < ApplicationController
7
3
  <% actions.each do |action| -%>
@@ -55,7 +55,7 @@ module Rails
55
55
  end
56
56
 
57
57
  def gem_entry_for(*gem_name_and_version)
58
- gem_name_and_version.map! { |segment| "'#{segment}'" }
58
+ gem_name_and_version.map! { |segment| "\"#{segment}\"" }
59
59
  "gem #{gem_name_and_version.join(", ")}"
60
60
  end
61
61
  end
@@ -1,3 +1,3 @@
1
1
  class <%= class_name %>Generator < Rails::Generators::NamedBase
2
- source_root File.expand_path('templates', __dir__)
2
+ source_root File.expand_path("templates", __dir__)
3
3
  end
@@ -26,12 +26,16 @@ module Rails
26
26
  empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
27
27
  end
28
28
 
29
- remove_dir "app/mailers" if options[:skip_action_mailer]
29
+ empty_directory_with_keep_file "app/models/concerns"
30
+ empty_directory_with_keep_file "app/controllers/concerns"
31
+ remove_dir "app/mailers" if skip_action_mailer?
30
32
  remove_dir "app/jobs" if options[:skip_active_job]
31
33
  elsif full?
32
34
  empty_directory_with_keep_file "app/models"
33
35
  empty_directory_with_keep_file "app/controllers"
34
- empty_directory_with_keep_file "app/mailers" unless options[:skip_action_mailer]
36
+ empty_directory_with_keep_file "app/models/concerns"
37
+ empty_directory_with_keep_file "app/controllers/concerns"
38
+ empty_directory_with_keep_file "app/mailers" unless skip_action_mailer?
35
39
  empty_directory_with_keep_file "app/jobs" unless options[:skip_active_job]
36
40
 
37
41
  unless api?
@@ -51,7 +55,7 @@ module Rails
51
55
  end
52
56
 
53
57
  def license
54
- template "MIT-LICENSE"
58
+ template "MIT-LICENSE" unless inside_application?
55
59
  end
56
60
 
57
61
  def gemspec
@@ -65,6 +69,9 @@ module Rails
65
69
  def version_control
66
70
  if !options[:skip_git] && !options[:pretend]
67
71
  run "git init", capture: options[:quiet], abort_on_failure: false
72
+ if user_default_branch.strip.empty?
73
+ `git symbolic-ref HEAD refs/heads/main`
74
+ end
68
75
  end
69
76
  end
70
77
 
@@ -87,12 +94,18 @@ module Rails
87
94
  def test
88
95
  template "test/test_helper.rb"
89
96
  template "test/%namespaced_name%_test.rb"
90
- append_file "Rakefile", <<-EOF
91
97
 
92
- #{rakefile_test_tasks}
93
- task default: :test
94
- EOF
95
98
  if engine?
99
+ empty_directory_with_keep_file "test/fixtures/files"
100
+ empty_directory_with_keep_file "test/controllers"
101
+ empty_directory_with_keep_file "test/mailers"
102
+ empty_directory_with_keep_file "test/models"
103
+ empty_directory_with_keep_file "test/integration"
104
+
105
+ unless api?
106
+ empty_directory_with_keep_file "test/helpers"
107
+ end
108
+
96
109
  template "test/integration/navigation_test.rb"
97
110
  end
98
111
  end
@@ -103,11 +116,8 @@ task default: :test
103
116
  opts = options.transform_keys(&:to_sym).except(*DUMMY_IGNORE_OPTIONS)
104
117
  opts[:force] = force
105
118
  opts[:skip_bundle] = true
106
- opts[:skip_spring] = true
107
- opts[:skip_listen] = true
108
119
  opts[:skip_git] = true
109
- opts[:skip_turbolinks] = true
110
- opts[:skip_webpack_install] = true
120
+ opts[:skip_hotwire] = true
111
121
  opts[:dummy_app] = true
112
122
 
113
123
  invoke Rails::Generators::AppGenerator,
@@ -124,10 +134,16 @@ task default: :test
124
134
  if mountable?
125
135
  template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true
126
136
  end
137
+ if engine? && !api?
138
+ insert_into_file "#{dummy_path}/config/application.rb", indent(<<~RUBY, 4), after: /^\s*config\.load_defaults.*\n/
139
+
140
+ # For compatibility with applications that use this config
141
+ config.action_controller.include_all_helpers = false
142
+ RUBY
143
+ end
127
144
  end
128
145
 
129
- def test_dummy_assets
130
- template "rails/javascripts.js", "#{dummy_path}/app/javascript/packs/application.js", force: true
146
+ def test_dummy_sprocket_assets
131
147
  template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true
132
148
  template "rails/dummy_manifest.js", "#{dummy_path}/app/assets/config/manifest.js", force: true
133
149
  end
@@ -175,6 +191,11 @@ task default: :test
175
191
  append_file gemfile_in_app_path, entry
176
192
  end
177
193
  end
194
+
195
+ private
196
+ def user_default_branch
197
+ @user_default_branch ||= `git config init.defaultbranch`
198
+ end
178
199
  end
179
200
 
180
201
  module Generators
@@ -205,18 +226,26 @@ task default: :test
205
226
  def initialize(*args)
206
227
  @dummy_path = nil
207
228
  super
229
+
230
+ if !engine? || !with_dummy_app?
231
+ self.options = options.merge(skip_asset_pipeline: true).freeze
232
+ end
208
233
  end
209
234
 
210
235
  public_task :set_default_accessors!
211
236
  public_task :create_root
212
237
 
238
+ def target_rails_prerelease
239
+ super("plugin new")
240
+ end
241
+
213
242
  def create_root_files
214
243
  build(:readme)
215
244
  build(:rakefile)
216
245
  build(:gemspec) unless options[:skip_gemspec]
217
246
  build(:license)
218
247
  build(:gitignore) unless options[:skip_git]
219
- build(:gemfile) unless options[:skip_gemfile]
248
+ build(:gemfile)
220
249
  build(:version_control)
221
250
  end
222
251
 
@@ -284,6 +313,34 @@ task default: :test
284
313
  end
285
314
 
286
315
  private
316
+ def gemfile_entries
317
+ [
318
+ rails_gemfile_entry,
319
+ simplify_gemfile_entries(
320
+ web_server_gemfile_entry,
321
+ database_gemfile_entry,
322
+ asset_pipeline_gemfile_entry,
323
+ ),
324
+ ].flatten.compact
325
+ end
326
+
327
+ def rails_gemfile_entry
328
+ if options[:skip_gemspec]
329
+ super
330
+ elsif rails_prerelease?
331
+ super.dup.tap do |entry|
332
+ entry.comment = <<~COMMENT
333
+ Your gem is dependent on a prerelease version of Rails. Once you can lock this
334
+ dependency down to a specific version, move it to your gemspec.
335
+ COMMENT
336
+ end
337
+ end
338
+ end
339
+
340
+ def simplify_gemfile_entries(*gemfile_entries)
341
+ gemfile_entries.flatten.compact.map { |entry| GemfileEntry.floats(entry.name) }
342
+ end
343
+
287
344
  def create_dummy_app(path = nil)
288
345
  dummy_path(path) if path
289
346
 
@@ -291,7 +348,7 @@ task default: :test
291
348
  mute do
292
349
  build(:generate_test_dummy)
293
350
  build(:test_dummy_config)
294
- build(:test_dummy_assets)
351
+ build(:test_dummy_sprocket_assets) unless skip_sprockets?
295
352
  build(:test_dummy_clean)
296
353
  # ensure that bin/rails has proper dummy_path
297
354
  build(:bin, true)
@@ -373,6 +430,10 @@ task default: :test
373
430
  end
374
431
  end
375
432
 
433
+ def rails_version_specifier(gem_version = Rails.gem_version)
434
+ [">= #{gem_version}"]
435
+ end
436
+
376
437
  def valid_const?
377
438
  if /-\d/.match?(original_name)
378
439
  raise Error, "Invalid plugin name #{original_name}. Please give a name which does not contain a namespace starting with numeric characters."
@@ -393,18 +454,6 @@ task default: :test
393
454
  defined?(::PluginBuilder) ? ::PluginBuilder : Rails::PluginBuilder
394
455
  end
395
456
 
396
- def rakefile_test_tasks
397
- <<-RUBY
398
- require "rake/testtask"
399
-
400
- Rake::TestTask.new(:test) do |t|
401
- t.libs << 'test'
402
- t.pattern = 'test/**/*_test.rb'
403
- t.verbose = false
404
- end
405
- RUBY
406
- end
407
-
408
457
  def dummy_path(path = nil)
409
458
  @dummy_path = path if path
410
459
  @dummy_path || options[:dummy_path]
@@ -8,9 +8,11 @@ Gem::Specification.new do |spec|
8
8
  spec.homepage = "TODO"
9
9
  spec.summary = "TODO: Summary of <%= camelized_modules %>."
10
10
  spec.description = "TODO: Description of <%= camelized_modules %>."
11
+ <%- unless inside_application? -%>
11
12
  spec.license = "MIT"
13
+ <%- end -%>
12
14
 
13
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host"
14
16
  # to allow pushing to a single host or delete this section to allow pushing to any host.
15
17
  spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
18
 
@@ -18,7 +20,9 @@ Gem::Specification.new do |spec|
18
20
  spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
19
21
  spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
22
 
21
- 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
22
26
 
23
- <%= '# ' if options.dev? || options.edge? || options.master? -%>spec.add_dependency "rails", "<%= Array(rails_version_specifier).join('", "') %>"
27
+ <%= "# " if rails_prerelease? -%>spec.add_dependency "rails", "<%= Array(rails_version_specifier).join('", "') %>"
24
28
  end