Skip to content

Commit f39bd7e

Browse files
authored
Migrate to Rails 7.1 Settings (#1707)
* Migrate to Rails 7.1 Settings * Documentation
1 parent aaf0e67 commit f39bd7e

File tree

3 files changed

+33
-44
lines changed

3 files changed

+33
-44
lines changed

Configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Notes:
8989
| PWP__SHOW_VERSION | Show the version in the footer | `true` |
9090
| PWP__SHOW_GDPR_CONSENT_BANNER | Optionally enable or disable the GDPR cookie consent banner. | `true` |
9191
| PWP__TIMEZONE | Set the application wide timezone. Use a valid timezone string (see note below). | `America/New_York` |
92+
| SECRET_KEY_BASE | A secret key that is used for various security-related features, including session cookie encryption and other cryptographic operations. Use `/opt/PasswordPusher/bin/rails secret` to generate a random key string. [See the SECRET_KEY_BASE wiki page.](https://github.com/pglombardo/PasswordPusher/wiki/SECRET_KEY_BASE)| _Randomly Generated on boot_ |
9293

9394
_Note_: The list of valid timezone strings can be found at [https://en.wikipedia.org/wiki/List_of_tz_database_time_zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
9495

config/initializers/new_framework_defaults_7_1.rb

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
# Be sure to restart your server when you modify this file.
34
#
45
# This file eases your Rails 7.1 framework defaults upgrade.
@@ -14,21 +15,21 @@
1415
# to manually require files that are managed by the autoloader, which you shouldn't do anyway.
1516
# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size
1617
# of the bootsnap cache if you use it.
17-
# Rails.application.config.add_autoload_paths_to_load_path = false
18+
Rails.application.config.add_autoload_paths_to_load_path = false
1819

1920
# Remove the default X-Download-Options headers since it is used only by Internet Explorer.
2021
# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`.
21-
# Rails.application.config.action_dispatch.default_headers = {
22-
# "X-Frame-Options" => "SAMEORIGIN",
23-
# "X-XSS-Protection" => "0",
24-
# "X-Content-Type-Options" => "nosniff",
25-
# "X-Permitted-Cross-Domain-Policies" => "none",
26-
# "Referrer-Policy" => "strict-origin-when-cross-origin"
27-
# }
22+
Rails.application.config.action_dispatch.default_headers = {
23+
'X-Frame-Options' => 'SAMEORIGIN',
24+
'X-XSS-Protection' => '0',
25+
'X-Content-Type-Options' => 'nosniff',
26+
'X-Permitted-Cross-Domain-Policies' => 'none',
27+
'Referrer-Policy' => 'strict-origin-when-cross-origin'
28+
}
2829

2930
# Do not treat an `ActionController::Parameters` instance
3031
# as equal to an equivalent `Hash` by default.
31-
# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false
32+
Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false
3233

3334
# Active Record Encryption now uses SHA-256 as its hash digest algorithm. Important: If you have
3435
# data encrypted with previous Rails versions, there are two scenarios to consider:
@@ -49,7 +50,7 @@
4950
# Instead, run these callbacks on the instance most likely to have internal
5051
# state which matches what was committed to the database, typically the last
5152
# instance to save.
52-
# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false
53+
Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false
5354

5455
# Configures SQLite with a strict strings mode, which disables double-quoted string literals.
5556
#
@@ -58,10 +59,10 @@
5859
# it then considers them as string literals. Because of this, typos can silently go unnoticed.
5960
# For example, it is possible to create an index for a non existing column.
6061
# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details.
61-
# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true
62+
Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true
6263

6364
# Disable deprecated singular associations names
64-
# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false
65+
Rails.application.config.active_record.allow_deprecated_singular_associations_name = false
6566

6667
# Enable the Active Job `BigDecimal` argument serializer, which guarantees
6768
# roundtripping. Without this serializer, some queue adapters may serialize
@@ -71,18 +72,18 @@
7172
# replicas will not be able to deserialize `BigDecimal` arguments from this
7273
# serializer. Therefore, this setting should only be enabled after all replicas
7374
# have been successfully upgraded to Rails 7.1.
74-
# Rails.application.config.active_job.use_big_decimal_serializer = true
75+
Rails.application.config.active_job.use_big_decimal_serializer = true
7576

7677
# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or
7778
# `write` are given an invalid `expires_at` or `expires_in` time.
7879
# Options are `true`, and `false`. If `false`, the exception will be reported
7980
# as `handled` and logged instead.
80-
# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true
81+
Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true
8182

8283
# Specify whether Query Logs will format tags using the SQLCommenter format
8384
# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format.
8485
# Options are `:legacy` and `:sqlcommenter`.
85-
# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter
86+
Rails.application.config.active_record.query_log_tags_format = :sqlcommenter
8687

8788
# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier`
8889
# instances.
@@ -110,7 +111,7 @@
110111
# that have not yet been upgraded must be able to read messages from upgraded
111112
# servers, first deploy without changing the serializer, then set the serializer
112113
# in a subsequent deploy.
113-
# Rails.application.config.active_support.message_serializer = :json_allow_marshal
114+
Rails.application.config.active_support.message_serializer = :json_allow_marshal
114115

115116
# Enable a performance optimization that serializes message data and metadata
116117
# together. This changes the message format, so messages serialized this way
@@ -121,41 +122,39 @@
121122
# not yet been upgraded must be able to read messages from upgraded servers,
122123
# leave this optimization off on the first deploy, then enable it on a
123124
# subsequent deploy.
124-
# Rails.application.config.active_support.use_message_serializer_for_metadata = true
125+
Rails.application.config.active_support.use_message_serializer_for_metadata = true
125126

126127
# Set the maximum size for Rails log files.
127128
#
128129
# `config.load_defaults 7.1` does not set this value for environments other than
129130
# development and test.
130131
#
131-
# if Rails.env.local?
132-
# Rails.application.config.log_file_size = 100 * 1024 * 1024
133-
# end
132+
Rails.application.config.log_file_size = 100 * 1024 * 1024 if Rails.env.local?
134133

135134
# Enable raising on assignment to attr_readonly attributes. The previous
136135
# behavior would allow assignment but silently not persist changes to the
137136
# database.
138-
# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true
137+
Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true
139138

140139
# Enable validating only parent-related columns for presence when the parent is mandatory.
141140
# The previous behavior was to validate the presence of the parent record, which performed an extra query
142141
# to get the parent every time the child record was updated, even when parent has not changed.
143-
# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false
142+
Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false
144143

145144
# Enable precompilation of `config.filter_parameters`. Precompilation can
146145
# improve filtering performance, depending on the quantity and types of filters.
147-
# Rails.application.config.precompile_filter_parameters = true
146+
Rails.application.config.precompile_filter_parameters = true
148147

149148
# Enable before_committed! callbacks on all enrolled records in a transaction.
150149
# The previous behavior was to only run the callbacks on the first copy of a record
151150
# if there were multiple copies of the same record enrolled in the transaction.
152-
# Rails.application.config.active_record.before_committed_on_all_records = true
151+
Rails.application.config.active_record.before_committed_on_all_records = true
153152

154153
# Disable automatic column serialization into YAML.
155154
# To keep the historic behavior, you can set it to `YAML`, however it is
156155
# recommended to explicitly define the serialization method for each column
157156
# rather than to rely on a global default.
158-
# Rails.application.config.active_record.default_column_serializer = nil
157+
Rails.application.config.active_record.default_column_serializer = nil
159158

160159
# Enable a performance optimization that serializes Active Record models
161160
# in a faster and more compact way.
@@ -164,20 +163,20 @@
164163
# not yet been upgraded must be able to read caches from upgraded servers,
165164
# leave this optimization off on the first deploy, then enable it on a
166165
# subsequent deploy.
167-
# Rails.application.config.active_record.marshalling_format_version = 7.1
166+
Rails.application.config.active_record.marshalling_format_version = 7.1
168167

169168
# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model.
170169
# This matches the behaviour of all other callbacks.
171170
# In previous versions of Rails, they ran in the inverse order.
172-
# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true
171+
Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true
173172

174173
# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`.
175174
#
176-
# Rails.application.config.active_record.commit_transaction_on_non_local_return = true
175+
Rails.application.config.active_record.commit_transaction_on_non_local_return = true
177176

178177
# Controls when to generate a value for <tt>has_secure_token</tt> declarations.
179178
#
180-
# Rails.application.config.active_record.generate_secure_token_on = :initialize
179+
Rails.application.config.active_record.generate_secure_token_on = :initialize
181180

182181
# ** Please read carefully, this must be configured in config/application.rb **
183182
# Change the format of the cache entry.
@@ -198,7 +197,7 @@
198197
#
199198
# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor.
200199
#
201-
# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
200+
Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
202201

203202
# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your
204203
# platform.
@@ -208,11 +207,11 @@
208207
#
209208
# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor.
210209
#
211-
# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
210+
Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
212211

213212
# Configure the log level used by the DebugExceptions middleware when logging
214213
# uncaught exceptions during requests
215-
# Rails.application.config.action_dispatch.debug_exception_log_level = :error
214+
Rails.application.config.action_dispatch.debug_exception_log_level = :error
216215

217216
# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5
218217
# parsers.
@@ -221,4 +220,4 @@
221220
#
222221
# In previous versions of Rails, these test helpers always used an HTML4 parser.
223222
#
224-
# Rails.application.config.dom_testing_default_html_version = :html5
223+
Rails.application.config.dom_testing_default_html_version = :html5

config/initializers/secret_token.rb

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)