railties 7.2.0 → 8.0.0.beta1

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 (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -254
  3. data/lib/minitest/rails_plugin.rb +1 -1
  4. data/lib/rails/application/configuration.rb +15 -2
  5. data/lib/rails/application/default_middleware_stack.rb +4 -0
  6. data/lib/rails/application/finisher.rb +2 -2
  7. data/lib/rails/application/routes_reloader.rb +11 -1
  8. data/lib/rails/application.rb +12 -0
  9. data/lib/rails/code_statistics.rb +128 -86
  10. data/lib/rails/code_statistics_calculator.rb +78 -76
  11. data/lib/rails/command/helpers/editor.rb +1 -1
  12. data/lib/rails/commands/app/update_command.rb +10 -9
  13. data/lib/rails/commands/console/irb_console.rb +1 -2
  14. data/lib/rails/commands/credentials/USAGE +4 -4
  15. data/lib/rails/commands/credentials/credentials_command.rb +5 -1
  16. data/lib/rails/commands/dev/dev_command.rb +1 -1
  17. data/lib/rails/commands/devcontainer/devcontainer_command.rb +1 -1
  18. data/lib/rails/commands/stats/stats_command.rb +19 -0
  19. data/lib/rails/dev_caching.rb +2 -2
  20. data/lib/rails/engine/configuration.rb +3 -1
  21. data/lib/rails/engine/lazy_route_set.rb +109 -0
  22. data/lib/rails/engine.rb +10 -5
  23. data/lib/rails/gem_version.rb +3 -3
  24. data/lib/rails/generators/app_base.rb +46 -24
  25. data/lib/rails/generators/database.rb +102 -68
  26. data/lib/rails/generators/erb/authentication/authentication_generator.rb +15 -0
  27. data/lib/rails/generators/erb/authentication/templates/views/passwords/edit.html.erb +9 -0
  28. data/lib/rails/generators/erb/authentication/templates/views/passwords/new.html.erb +8 -0
  29. data/lib/rails/generators/erb/authentication/templates/views/sessions/new.html.erb +11 -0
  30. data/lib/rails/generators/generated_attribute.rb +16 -11
  31. data/lib/rails/generators/rails/app/app_generator.rb +22 -32
  32. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +12 -3
  33. data/lib/rails/generators/rails/app/templates/Gemfile.tt +23 -8
  34. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +6 -11
  35. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +10 -3
  36. data/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.js +3 -3
  37. data/lib/rails/generators/rails/app/templates/bin/dev.tt +1 -0
  38. data/lib/rails/generators/rails/app/templates/bin/setup.tt +5 -7
  39. data/lib/rails/generators/rails/app/templates/bin/thrust.tt +4 -0
  40. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +23 -0
  41. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +23 -0
  42. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +40 -0
  43. data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +23 -0
  44. data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +124 -0
  45. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +12 -23
  46. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +34 -51
  47. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +5 -19
  48. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +0 -7
  49. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +1 -1
  50. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +25 -0
  51. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +13 -3
  52. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +5 -3
  53. data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +4 -3
  54. data/lib/rails/generators/rails/app/templates/dockerignore.tt +1 -2
  55. data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +1 -1
  56. data/lib/rails/generators/rails/app/templates/gitignore.tt +1 -2
  57. data/lib/rails/generators/rails/app/templates/kamal-secrets.tt +17 -0
  58. data/lib/rails/generators/rails/app/templates/public/400.html +114 -0
  59. data/lib/rails/generators/rails/app/templates/public/404.html +113 -66
  60. data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +113 -65
  61. data/lib/rails/generators/rails/app/templates/public/422.html +113 -66
  62. data/lib/rails/generators/rails/app/templates/public/500.html +113 -65
  63. data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
  64. data/lib/rails/generators/rails/app/templates/public/icon.svg +2 -2
  65. data/lib/rails/generators/rails/authentication/USAGE +6 -0
  66. data/lib/rails/generators/rails/authentication/authentication_generator.rb +54 -0
  67. data/lib/rails/generators/rails/authentication/templates/controllers/concerns/authentication.rb +55 -0
  68. data/lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb +33 -0
  69. data/lib/rails/generators/rails/authentication/templates/controllers/sessions_controller.rb +21 -0
  70. data/lib/rails/generators/rails/authentication/templates/mailers/passwords_mailer.rb +6 -0
  71. data/lib/rails/generators/rails/authentication/templates/models/current.rb +4 -0
  72. data/lib/rails/generators/rails/authentication/templates/models/session.rb +3 -0
  73. data/lib/rails/generators/rails/authentication/templates/models/user.rb +6 -0
  74. data/lib/rails/generators/rails/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb +7 -0
  75. data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.html.erb +4 -0
  76. data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.text.erb +2 -0
  77. data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +4 -0
  78. data/lib/rails/generators/rails/db/system/change/change_generator.rb +1 -1
  79. data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +5 -3
  80. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +1 -1
  81. data/lib/rails/generators/rails/plugin/plugin_generator.rb +11 -11
  82. data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +1 -1
  83. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +2 -2
  84. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -2
  85. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +3 -3
  86. data/lib/rails/generators/rails/script/USAGE +18 -0
  87. data/lib/rails/generators/rails/script/script_generator.rb +18 -0
  88. data/lib/rails/generators/rails/script/templates/script.rb.tt +3 -0
  89. data/lib/rails/generators.rb +7 -2
  90. data/lib/rails/info_controller.rb +10 -2
  91. data/lib/rails/rack/silence_request.rb +33 -0
  92. data/lib/rails/rack.rb +1 -0
  93. data/lib/rails/railtie.rb +13 -13
  94. data/lib/rails/source_annotation_extractor.rb +31 -14
  95. data/lib/rails/tasks/statistics.rake +13 -28
  96. data/lib/rails/templates/rails/info/notes.html.erb +65 -0
  97. metadata +45 -25
  98. data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -2
  99. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb.tt +0 -4
  100. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb.tt +0 -4
  101. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt +0 -70
  102. data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +0 -13
  103. data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +0 -13
  104. data/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js.tt +0 -10
  105. data/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js.tt +0 -6
  106. data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js.tt +0 -17
@@ -3,9 +3,7 @@ require "active_support/core_ext/integer/time"
3
3
  Rails.application.configure do
4
4
  # Settings specified here will take precedence over those in config/application.rb.
5
5
 
6
- # In the development environment your application's code is reloaded any time
7
- # it changes. This slows down response time but is perfect for development
8
- # since you don't have to restart the web server when you make code changes.
6
+ # Make code changes take effect immediately without server restart.
9
7
  config.enable_reloading = true
10
8
 
11
9
  # Do not eager load code on boot.
@@ -17,21 +15,20 @@ Rails.application.configure do
17
15
  # Enable server timing.
18
16
  config.server_timing = true
19
17
 
20
- # Enable/disable caching. By default caching is disabled.
21
- # Run rails dev:cache to toggle caching.
18
+ # Enable/disable Action Controller caching. By default Action Controller caching is disabled.
19
+ # Run rails dev:cache to toggle Action Controller caching.
22
20
  if Rails.root.join("tmp/caching-dev.txt").exist?
23
21
  <%- unless options.api? -%>
24
22
  config.action_controller.perform_caching = true
25
23
  config.action_controller.enable_fragment_cache_logging = true
26
-
27
24
  <%- end -%>
28
- config.cache_store = :memory_store
29
- config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
25
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
30
26
  else
31
27
  config.action_controller.perform_caching = false
32
-
33
- config.cache_store = :null_store
34
28
  end
29
+
30
+ # Change to :null_store to avoid any caching.
31
+ config.cache_store = :memory_store
35
32
  <%- unless skip_active_storage? -%>
36
33
 
37
34
  # Store uploaded files on the local file system (see config/storage.yml for options).
@@ -42,22 +39,16 @@ Rails.application.configure do
42
39
  # Don't care if the mailer can't send.
43
40
  config.action_mailer.raise_delivery_errors = false
44
41
 
45
- # Disable caching for Action Mailer templates even if Action Controller
46
- # caching is enabled.
42
+ # Make template changes take effect immediately.
47
43
  config.action_mailer.perform_caching = false
48
44
 
45
+ # Set localhost to be used by links generated in mailer templates.
49
46
  config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
50
47
  <%- end -%>
51
48
 
52
49
  # Print deprecation notices to the Rails logger.
53
50
  config.active_support.deprecation = :log
54
51
 
55
- # Raise exceptions for disallowed deprecations.
56
- config.active_support.disallowed_deprecation = :raise
57
-
58
- # Tell Active Support which deprecation messages to disallow.
59
- config.active_support.disallowed_deprecation_warnings = []
60
-
61
52
  <%- unless options.skip_active_record? -%>
62
53
  # Raise an error on page load if there are pending migrations.
63
54
  config.active_record.migration_error = :page_load
@@ -65,16 +56,14 @@ Rails.application.configure do
65
56
  # Highlight code that triggered database queries in logs.
66
57
  config.active_record.verbose_query_logs = true
67
58
 
59
+ # Append comments with runtime information tags to SQL queries in logs.
60
+ config.active_record.query_log_tags_enabled = true
61
+
68
62
  <%- end -%>
69
63
  <%- unless options[:skip_active_job] -%>
70
64
  # Highlight code that enqueued background job in logs.
71
65
  config.active_job.verbose_enqueue_logs = true
72
66
 
73
- <%- end -%>
74
- <%- unless skip_sprockets? -%>
75
- # Suppress logger output for asset requests.
76
- config.assets.quiet = true
77
-
78
67
  <%- end -%>
79
68
  # Raises error for missing translations.
80
69
  # config.i18n.raise_on_missing_translations = true
@@ -6,55 +6,30 @@ Rails.application.configure do
6
6
  # Code is not reloaded between requests.
7
7
  config.enable_reloading = false
8
8
 
9
- # Eager load code on boot. This eager loads most of Rails and
10
- # your application in memory, allowing both threaded web servers
11
- # and those relying on copy on write to perform better.
12
- # Rake tasks automatically ignore this option for performance.
9
+ # Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
13
10
  config.eager_load = true
14
11
 
15
- # Full error reports are disabled and caching is turned on.
12
+ # Full error reports are disabled.
16
13
  config.consider_all_requests_local = false
17
14
  <%- unless options.api? -%>
15
+
16
+ # Turn on fragment caching in view templates.
18
17
  config.action_controller.perform_caching = true
19
18
  <%- end -%>
20
19
 
21
- # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
22
- # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
23
- # config.require_master_key = true
24
-
25
- # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
26
- # config.public_file_server.enabled = false
27
-
28
- <%- unless skip_sprockets? -%>
29
- # Compress CSS using a preprocessor.
30
- # config.assets.css_compressor = :sass
20
+ # Cache assets for far-future expiry since they are all digest stamped.
21
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
31
22
 
32
- # Do not fall back to assets pipeline if a precompiled asset is missed.
33
- config.assets.compile = false
34
-
35
- <%- end -%>
36
23
  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
37
24
  # config.asset_host = "http://assets.example.com"
38
25
 
39
- # Specifies the header that your server uses for sending files.
40
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
41
- # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
42
-
43
26
  <%- unless skip_active_storage? -%>
44
27
  # Store uploaded files on the local file system (see config/storage.yml for options).
45
28
  config.active_storage.service = :local
46
29
 
47
- <%- end -%>
48
- <%- unless skip_action_cable? -%>
49
- # Mount Action Cable outside main process or domain.
50
- # config.action_cable.mount_path = nil
51
- # config.action_cable.url = "wss://example.com/cable"
52
- # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
53
-
54
30
  <%- end -%>
55
31
  # Assume all access to the app is happening through a SSL-terminating reverse proxy.
56
- # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
57
- # config.assume_ssl = true
32
+ config.assume_ssl = true
58
33
 
59
34
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
60
35
  config.force_ssl = true
@@ -62,48 +37,55 @@ Rails.application.configure do
62
37
  # Skip http-to-https redirect for the default health check endpoint.
63
38
  # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
64
39
 
65
- # Log to STDOUT by default
66
- config.logger = ActiveSupport::Logger.new(STDOUT)
67
- .tap { |logger| logger.formatter = ::Logger::Formatter.new }
68
- .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
69
-
70
- # Prepend all log lines with the following tags.
40
+ # Log to STDOUT with the current request id as a default log tag.
71
41
  config.log_tags = [ :request_id ]
42
+ config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
72
43
 
73
- # "info" includes generic and useful information about system operation, but avoids logging too much
74
- # information to avoid inadvertent exposure of personally identifiable information (PII). If you
75
- # want to log everything, set the level to "debug".
44
+ # Change to "debug" to log everything (including potentially personally-identifiable information!)
76
45
  config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
77
46
 
78
- # Use a different cache store in production.
47
+ # Prevent health checks from clogging up the logs.
48
+ config.silence_healthcheck_path = "/up"
49
+
50
+ # Don't log any deprecations.
51
+ config.active_support.report_deprecations = false
52
+
53
+ # Replace the default in-process memory cache store with a durable alternative.
79
54
  # config.cache_store = :mem_cache_store
80
55
 
81
56
  <%- unless options[:skip_active_job] -%>
82
- # Use a real queuing backend for Active Job (and separate queues per environment).
57
+ # Replace the default in-process and non-durable queuing backend for Active Job.
83
58
  # config.active_job.queue_adapter = :resque
84
- # config.active_job.queue_name_prefix = "<%= app_name %>_production"
85
59
 
86
60
  <%- end -%>
87
61
  <%- unless options.skip_action_mailer? -%>
88
- # Disable caching for Action Mailer templates even if Action Controller
89
- # caching is enabled.
90
- config.action_mailer.perform_caching = false
91
-
92
62
  # Ignore bad email addresses and do not raise email delivery errors.
93
63
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
94
64
  # config.action_mailer.raise_delivery_errors = false
95
65
 
66
+ # Set host to be used by links generated in mailer templates.
67
+ config.action_mailer.default_url_options = { host: "example.com" }
68
+
69
+ # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
70
+ # config.action_mailer.smtp_settings = {
71
+ # user_name: Rails.application.credentials.dig(:smtp, :user_name),
72
+ # password: Rails.application.credentials.dig(:smtp, :password),
73
+ # address: "smtp.example.com",
74
+ # port: 587,
75
+ # authentication: :plain
76
+ # }
77
+
96
78
  <%- end -%>
97
79
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
98
80
  # the I18n.default_locale when a translation cannot be found).
99
81
  config.i18n.fallbacks = true
100
-
101
- # Don't log any deprecations.
102
- config.active_support.report_deprecations = false
103
82
  <%- unless options.skip_active_record? -%>
104
83
 
105
84
  # Do not dump schema after migrations.
106
85
  config.active_record.dump_schema_after_migration = false
86
+
87
+ # Only use :id for inspections in production.
88
+ config.active_record.attributes_for_inspect = [ :id ]
107
89
  <%- end -%>
108
90
 
109
91
  # Enable DNS rebinding protection and other `Host` header attacks.
@@ -111,6 +93,7 @@ Rails.application.configure do
111
93
  # "example.com", # Allow requests from example.com
112
94
  # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
113
95
  # ]
96
+ #
114
97
  # Skip DNS rebinding protection for the default health check endpoint.
115
98
  # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
116
99
  end
@@ -1,5 +1,3 @@
1
- require "active_support/core_ext/integer/time"
2
-
3
1
  # The test environment is used exclusively to run your application's
4
2
  # test suite. You never need to work with it otherwise. Remember that
5
3
  # your test database is "scratch space" for the test suite and is wiped
@@ -17,12 +15,11 @@ Rails.application.configure do
17
15
  # loading is working properly before deploying your code.
18
16
  config.eager_load = ENV["CI"].present?
19
17
 
20
- # Configure public file server for tests with Cache-Control for performance.
21
- config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
18
+ # Configure public file server for tests with cache-control for performance.
19
+ config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
22
20
 
23
- # Show full error reports and disable caching.
21
+ # Show full error reports.
24
22
  config.consider_all_requests_local = true
25
- config.action_controller.perform_caching = false
26
23
  config.cache_store = :null_store
27
24
 
28
25
  # Render exception templates for rescuable exceptions and raise for other exceptions.
@@ -37,29 +34,18 @@ Rails.application.configure do
37
34
 
38
35
  <%- end -%>
39
36
  <%- unless options.skip_action_mailer? -%>
40
- # Disable caching for Action Mailer templates even if Action Controller
41
- # caching is enabled.
42
- config.action_mailer.perform_caching = false
43
-
44
37
  # Tell Action Mailer not to deliver emails to the real world.
45
38
  # The :test delivery method accumulates sent emails in the
46
39
  # ActionMailer::Base.deliveries array.
47
40
  config.action_mailer.delivery_method = :test
48
41
 
49
- # Unlike controllers, the mailer instance doesn't have any context about the
50
- # incoming request so you'll need to provide the :host parameter yourself.
51
- config.action_mailer.default_url_options = { host: "www.example.com" }
42
+ # Set host to be used by links generated in mailer templates.
43
+ config.action_mailer.default_url_options = { host: "example.com" }
52
44
 
53
45
  <%- end -%>
54
46
  # Print deprecation notices to the stderr.
55
47
  config.active_support.deprecation = :stderr
56
48
 
57
- # Raise exceptions for disallowed deprecations.
58
- config.active_support.disallowed_deprecation = :raise
59
-
60
- # Tell Active Support which deprecation messages to disallow.
61
- config.active_support.disallowed_deprecation_warnings = []
62
-
63
49
  # Raises error for missing translations.
64
50
  # config.i18n.raise_on_missing_translations = true
65
51
 
@@ -5,10 +5,3 @@ 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
- <% if options[:asset_pipeline] == "sprockets" -%>
9
-
10
- # Precompile additional assets.
11
- # application.js, application.css, and all non-JS/CSS in the app/assets
12
- # folder are already added.
13
- # Rails.application.config.assets.precompile += %w( admin.js admin.css )
14
- <% end -%>
@@ -4,5 +4,5 @@
4
4
  # Use this to limit dissemination of sensitive information.
5
5
  # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
6
6
  Rails.application.config.filter_parameters += [
7
- :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
7
+ :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc
8
8
  ]
@@ -0,0 +1,25 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file eases your Rails 8.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 `8.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
+ ###
13
+ # Specifies whether `to_time` methods preserve the UTC offset of their receivers or preserves the timezone.
14
+ # If set to `:zone`, `to_time` methods will use the timezone of their receivers.
15
+ # If set to `:offset`, `to_time` methods will use the UTC offset.
16
+ # If `false`, `to_time` methods will convert to the local system UTC offset instead.
17
+ #++
18
+ # Rails.application.config.active_support.to_time_preserves_timezone = :zone
19
+
20
+ ###
21
+ # When both `If-Modified-Since` and `If-None-Match` are provided by the client
22
+ # only consider `If-None-Match` as specified by RFC 7232 Section 6.
23
+ # If set to `false` both conditions need to be satisfied.
24
+ #++
25
+ # Rails.application.config.action_dispatch.strict_freshness = true
@@ -1,13 +1,17 @@
1
1
  # This configuration file will be evaluated by Puma. The top-level methods that
2
2
  # are invoked here are part of Puma's configuration DSL. For more information
3
3
  # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
4
-
4
+ #
5
5
  # Puma starts a configurable number of processes (workers) and each process
6
6
  # serves each request in a thread from an internal thread pool.
7
7
  #
8
+ # You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
9
+ # should only set this value when you want to run 2 or more workers. The
10
+ # default is already 1.
11
+ #
8
12
  # The ideal number of threads per worker depends both on how much time the
9
13
  # application spends waiting for IO operations and on how much you wish to
10
- # to prioritize throughput over latency.
14
+ # prioritize throughput over latency.
11
15
  #
12
16
  # As a rule of thumb, increasing the number of threads will increase how much
13
17
  # traffic a given process can handle (throughput), but due to CRuby's
@@ -29,5 +33,11 @@ port ENV.fetch("PORT", 3000)
29
33
  # Allow puma to be restarted by `bin/rails restart` command.
30
34
  plugin :tmp_restart
31
35
 
32
- # Only use a pidfile when requested
36
+ <% unless skip_solid? -%>
37
+ # Run the Solid Queue supervisor inside of Puma for single-server deployments
38
+ plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
39
+
40
+ <% end -%>
41
+ # Specify the PID file. Defaults to tmp/pids/server.pid in development.
42
+ # In other environments, only set the PID file if requested.
33
43
  pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
@@ -5,10 +5,12 @@ Rails.application.routes.draw do
5
5
  # Can be used by load balancers and uptime monitors to verify that the app is live.
6
6
  get "up" => "rails/health#show", as: :rails_health_check
7
7
 
8
- # Render dynamic PWA files from app/views/pwa/*
9
- get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
10
- get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
8
+ <%- unless options.api? -%>
9
+ # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb)
10
+ # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
11
+ # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
11
12
 
13
+ <%- end -%>
12
14
  # Defines the root path route ("/")
13
15
  # root "posts#index"
14
16
  end
@@ -1,13 +1,14 @@
1
1
  #!/bin/bash -e
2
2
 
3
3
  # Enable jemalloc for reduced memory usage and latency.
4
- if [ -z "${LD_PRELOAD+x}" ] && [ -f /usr/lib/*/libjemalloc.so.2 ]; then
5
- export LD_PRELOAD="$(echo /usr/lib/*/libjemalloc.so.2)"
4
+ if [ -z "${LD_PRELOAD+x}" ]; then
5
+ LD_PRELOAD=$(find /usr/lib -name libjemalloc.so.2 -print -quit)
6
+ export LD_PRELOAD
6
7
  fi
7
8
 
8
9
  <% unless skip_active_record? -%>
9
10
  # If running the rails server then create or migrate existing database
10
- if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
11
+ if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then
11
12
  ./bin/rails db:prepare
12
13
  fi
13
14
 
@@ -7,9 +7,8 @@
7
7
  # Ignore bundler config.
8
8
  /.bundle
9
9
 
10
- # Ignore all environment files (except templates).
10
+ # Ignore all environment files.
11
11
  /.env*
12
- !/.env*.erb
13
12
 
14
13
  # Ignore all default key files.
15
14
  /config/master.key
@@ -24,7 +24,7 @@ jobs:
24
24
  run: bin/brakeman --no-pager
25
25
 
26
26
  <% end -%>
27
- <%- if options[:javascript] == "importmap" -%>
27
+ <%- if options[:javascript] == "importmap" && !options[:api] -%>
28
28
  scan_js:
29
29
  runs-on: ubuntu-latest
30
30
 
@@ -7,9 +7,8 @@
7
7
  # Ignore bundler config.
8
8
  /.bundle
9
9
 
10
- # Ignore all environment files (except templates).
10
+ # Ignore all environment files.
11
11
  /.env*
12
- !/.env*.erb
13
12
 
14
13
  # Ignore all logfiles and tempfiles.
15
14
  /log/*
@@ -0,0 +1,17 @@
1
+ # Secrets defined here are available for reference under registry/password, env/secret, builder/secrets,
2
+ # and accessories/*/env/secret in config/deploy.yml. All secrets should be pulled from either
3
+ # password manager, ENV, or a file. DO NOT ENTER RAW CREDENTIALS HERE! This file needs to be safe for git.
4
+
5
+ # Example of extracting secrets from 1password (or another compatible pw manager)
6
+ # SECRETS=$(kamal secrets fetch --adapter 1password --account your-account --from Vault/Item KAMAL_REGISTRY_PASSWORD RAILS_MASTER_KEY)
7
+ # KAMAL_REGISTRY_PASSWORD=$(kamal secrets extract KAMAL_REGISTRY_PASSWORD ${SECRETS})
8
+ # RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY ${SECRETS})
9
+
10
+ # Use a GITHUB_TOKEN if private repositories are needed for the image
11
+ # GITHUB_TOKEN=$(gh config get -h github.com oauth_token)
12
+
13
+ # Grab the registry password from ENV
14
+ KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD
15
+
16
+ # Improve security by using a password manager. Never check config/master.key into git!
17
+ RAILS_MASTER_KEY=$(cat config/master.key)
@@ -0,0 +1,114 @@
1
+ <!doctype html>
2
+
3
+ <html lang="en">
4
+
5
+ <head>
6
+
7
+ <title>The server cannot process the request due to a client error (400 Bad Request)</title>
8
+
9
+ <meta charset="utf-8">
10
+ <meta name="viewport" content="initial-scale=1, width=device-width">
11
+ <meta name="robots" content="noindex, nofollow">
12
+
13
+ <style>
14
+
15
+ *, *::before, *::after {
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ * {
20
+ margin: 0;
21
+ }
22
+
23
+ html {
24
+ font-size: 16px;
25
+ }
26
+
27
+ body {
28
+ background: #FFF;
29
+ color: #261B23;
30
+ display: grid;
31
+ font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Aptos, Roboto, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
32
+ font-size: clamp(1rem, 2.5vw, 2rem);
33
+ -webkit-font-smoothing: antialiased;
34
+ font-style: normal;
35
+ font-weight: 400;
36
+ letter-spacing: -0.0025em;
37
+ line-height: 1.4;
38
+ min-height: 100vh;
39
+ place-items: center;
40
+ text-rendering: optimizeLegibility;
41
+ -webkit-text-size-adjust: 100%;
42
+ }
43
+
44
+ a {
45
+ color: inherit;
46
+ font-weight: 700;
47
+ text-decoration: underline;
48
+ text-underline-offset: 0.0925em;
49
+ }
50
+
51
+ b, strong {
52
+ font-weight: 700;
53
+ }
54
+
55
+ i, em {
56
+ font-style: italic;
57
+ }
58
+
59
+ main {
60
+ display: grid;
61
+ gap: 1em;
62
+ padding: 2em;
63
+ place-items: center;
64
+ text-align: center;
65
+ }
66
+
67
+ main header {
68
+ width: min(100%, 12em);
69
+ }
70
+
71
+ main header svg {
72
+ height: auto;
73
+ max-width: 100%;
74
+ width: 100%;
75
+ }
76
+
77
+ main article {
78
+ width: min(100%, 30em);
79
+ }
80
+
81
+ main article p {
82
+ font-size: 75%;
83
+ }
84
+
85
+ main article br {
86
+
87
+ display: none;
88
+
89
+ @media(min-width: 48em) {
90
+ display: inline;
91
+ }
92
+
93
+ }
94
+
95
+ </style>
96
+
97
+ </head>
98
+
99
+ <body>
100
+
101
+ <!-- This file lives in public/400.html -->
102
+
103
+ <main>
104
+ <header>
105
+ <svg height="172" viewBox="0 0 480 172" width="480" xmlns="http://www.w3.org/2000/svg"><path d="m124.48 3.00509-45.6889 100.02991h26.2239v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.1833v-31.901l50.2851-103.27391zm115.583 168.69891c-40.822 0-64.884-35.146-64.884-85.7015 0-50.5554 24.062-85.700907 64.884-85.700907 40.823 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.061 85.7015-64.884 85.7015zm0-133.2831c-17.572 0-22.709 21.8984-22.709 47.5816 0 25.6835 5.137 47.5815 22.709 47.5815 17.303 0 22.71-21.898 22.71-47.5815 0-25.6832-5.407-47.5816-22.71-47.5816zm140.456 133.2831c-40.823 0-64.884-35.146-64.884-85.7015 0-50.5554 24.061-85.700907 64.884-85.700907 40.822 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.062 85.7015-64.884 85.7015zm0-133.2831c-17.573 0-22.71 21.8984-22.71 47.5816 0 25.6835 5.137 47.5815 22.71 47.5815 17.302 0 22.709-21.898 22.709-47.5815 0-25.6832-5.407-47.5816-22.709-47.5816z" fill="#f0eff0"/><path d="m123.606 85.4445c3.212 1.0523 5.538 4.2089 5.538 8.0301 0 6.1472-4.209 9.5254-11.298 9.5254h-15.617v-34.0033h14.565c7.089 0 11.353 3.1566 11.353 9.2484 0 3.6551-2.049 6.3134-4.541 7.1994zm-12.904-2.9905h5.095c2.603 0 3.988-.9968 3.988-3.1013 0-2.1044-1.385-3.0459-3.988-3.0459h-5.095zm0 6.6456v6.5902h5.981c2.492 0 3.877-1.3291 3.877-3.2674 0-2.049-1.385-3.3228-3.877-3.3228zm43.786 13.9004h-8.362v-1.274c-.831.831-3.323 1.717-5.981 1.717-4.929 0-9.083-2.769-9.083-8.0301 0-4.818 4.154-7.9193 9.581-7.9193 2.049 0 4.486.6646 5.483 1.3845v-1.606c0-1.606-.942-2.9905-3.046-2.9905-1.606 0-2.548.7199-2.935 1.8275h-8.197c.72-4.8181 4.985-8.6393 11.409-8.6393 7.088 0 11.131 3.7659 11.131 10.2453zm-8.362-6.9779v-1.4399c-.554-1.0522-2.049-1.7167-3.655-1.7167-1.717 0-3.434.7199-3.434 2.3813 0 1.7168 1.717 2.4367 3.434 2.4367 1.606 0 3.101-.6645 3.655-1.6614zm27.996 6.9779v-1.994c-1.163 1.329-3.599 2.548-6.147 2.548-7.199 0-11.131-5.8151-11.131-13.0145s3.932-13.0143 11.131-13.0143c2.548 0 4.984 1.2184 6.147 2.5475v-13.0697h8.695v35.997zm0-9.1931v-6.5902c-.664-1.3291-2.159-2.326-3.821-2.326-2.99 0-4.763 2.4368-4.763 5.6488s1.773 5.5934 4.763 5.5934c1.717 0 3.157-.9415 3.821-2.326zm35.471-2.049h-3.101v11.2421h-8.806v-34.0033h15.285c7.31 0 12.35 4.1535 12.35 11.5744 0 5.1503-2.603 8.6947-6.757 10.2453l7.975 12.1836h-9.858zm-3.101-15.2849v8.1962h5.538c3.156 0 4.596-1.606 4.596-4.0981s-1.44-4.0981-4.596-4.0981zm36.957 17.8323h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.515-13.0143 7.643 0 11.962 5.095 11.962 12.5159v2.1598h-16.115c.277 2.9905 1.827 4.5965 4.32 4.5965 1.772 0 3.156-.7753 3.655-2.4921zm-3.822-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm30.98 27.5234v-10.799c-1.163 1.329-3.6 2.548-6.147 2.548-7.2 0-11.132-5.9259-11.132-13.0145 0-7.144 3.932-13.0143 11.132-13.0143 2.547 0 4.984 1.2184 6.147 2.5475v-1.9937h8.695v33.726zm0-17.9981v-6.5902c-.665-1.3291-2.105-2.326-3.821-2.326-2.991 0-4.763 2.4368-4.763 5.6488s1.772 5.5934 4.763 5.5934c1.661 0 3.156-.9415 3.821-2.326zm36.789-15.7279v24.921h-8.695v-2.16c-1.329 1.551-3.821 2.714-6.646 2.714-5.482 0-8.75-3.5999-8.75-9.1379v-16.3371h8.64v14.288c0 2.1045.996 3.5997 3.212 3.5997 1.606 0 3.101-1.0522 3.544-2.769v-15.1187zm19.084 16.2263h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.515-13.0143 7.643 0 11.963 5.095 11.963 12.5159v2.1598h-16.116c.277 2.9905 1.828 4.5965 4.32 4.5965 1.772 0 3.156-.7753 3.655-2.4921zm-3.822-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm13.428 11.0206h8.474c.387 1.3845 1.606 2.1598 3.156 2.1598 1.44 0 2.548-.5538 2.548-1.7168 0-.9414-.72-1.2737-1.939-1.5506l-4.873-.9969c-4.154-.886-6.867-2.8797-6.867-7.2547 0-5.3165 4.762-8.4178 10.633-8.4178 6.812 0 10.522 3.1567 11.297 8.0855h-8.03c-.277-1.0522-1.052-1.9937-3.046-1.9937-1.273 0-2.326.5538-2.326 1.6614 0 .7753.554 1.163 1.717 1.3845l4.929 1.163c4.541 1.0522 6.978 3.4335 6.978 7.4763 0 5.3168-4.818 8.2518-10.91 8.2518-6.369 0-10.965-2.88-11.741-8.2518zm27.538-.8861v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.205v6.7564h-5.205v8.307c0 1.9383.941 2.769 2.658 2.769.941 0 1.993-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.871 0-9.193-2.769-9.193-9.0819z" fill="#d30001"/></svg>
106
+ </header>
107
+ <article>
108
+ <p><strong>The server cannot process the request due to a client error.</strong> Please check the request and try again. If you’re the application owner check the logs for more information.</p>
109
+ </article>
110
+ </main>
111
+
112
+ </body>
113
+
114
+ </html>