Skip to content

Commit 83606c4

Browse files
committed
Rails 7.1: rails app:update
This amended all the configuration files with manually-edited new diffs, getting rid of outdated configuration where known to be outdated. We wish to keep close to the default configuration, to make updates using these diff scripts easy.
1 parent f267ffe commit 83606c4

File tree

12 files changed

+352
-86
lines changed

12 files changed

+352
-86
lines changed

app/models/group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Group < ApplicationRecord
1313

1414
validates :name, presence: true, inclusion: { in: NAMES, message: 'Invalid name for Group' }
1515

16-
alias_attribute :city, :chapter
16+
alias city chapter
1717

1818
default_scope -> { joins(:chapter).includes(:chapter) }
1919

config/application.rb

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class Application < Rails::Application
2424
# Initialize configuration defaults for originally generated Rails version.
2525
config.load_defaults 7.0
2626

27+
config.autoload_lib(ignore: %w(assets tasks))
28+
2729
# Configuration for the application, engines, and railties goes here.
2830
#
2931
# These settings can be overridden in specific environments using the files
@@ -32,24 +34,9 @@ class Application < Rails::Application
3234
# config.time_zone = "Central Time (US & Canada)"
3335
# config.eager_load_paths << Rails.root.join("extras")
3436

35-
# Settings in config/environments/* take precedence over those specified here.
36-
# Application configuration can go into files in config/initializers
37-
# -- all .rb files in that directory are automatically loaded after loading
38-
# the framework and any gems in your application.
39-
40-
# Settings in config/environments/* take precedence over those specified here.
41-
# Application configuration should go into files in config/initializers
42-
# -- all .rb files in that directory are automatically loaded.
43-
44-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
45-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
4637
config.time_zone = 'London'
4738
config.active_record.default_timezone = :local
4839

49-
# Remove config.active_record.raise_in_transactional_callbacks, which is deprecated and removed without replacement, see
50-
# https://apidock.com/rails/v5.0.0.1/ActiveRecord/Transactions/ClassMethods/raise_in_transactional_callbacks%3D.
51-
# config.active_record.raise_in_transactional_callbacks = true
52-
5340
# Related to https://stackoverflow.com/questions/72970170/upgrading-to-rails-6-1-6-1-causes-psychdisallowedclass-tried-to-load-unspecif
5441
# and https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017
5542
config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time, ActiveSupport::TimeWithZone, ActiveSupport::TimeZone, ActiveSupport::HashWithIndifferentAccess]
@@ -59,6 +46,4 @@ class Application < Rails::Application
5946

6047
config.active_record.belongs_to_required_by_default = true
6148
end
62-
end
63-
64-
require 'csv' # the standard library CSV Class
49+
end

config/boot.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
22

33
require "bundler/setup" # Set up gems listed in the Gemfile.
4-
require "logger" # Fix concurrent-ruby removing logger dependency which Rails itself does not have

config/environments/development.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# In the development environment your application's code is reloaded any time
77
# it changes. This slows down response time but is perfect for development
88
# since you don't have to restart the web server when you make code changes.
9-
config.cache_classes = false
9+
config.enable_reloading = true
1010

1111
# Do not eager load code on boot.
1212
config.eager_load = false
@@ -56,6 +56,9 @@
5656
# Highlight code that triggered database queries in logs.
5757
config.active_record.verbose_query_logs = true
5858

59+
# Highlight code that enqueued background job in logs.
60+
config.active_job.verbose_enqueue_logs = true
61+
5962
# Suppress logger output for asset requests.
6063
config.assets.quiet = true
6164

@@ -65,8 +68,8 @@
6568
# Annotate rendered view with file names.
6669
# config.action_view.annotate_rendered_view_with_filenames = true
6770

68-
# Uncomment if you wish to allow Action Cable access from any origin.
69-
# config.action_cable.disable_request_forgery_protection = true
71+
# Raise error when a before_action's only/except options reference missing actions
72+
config.action_controller.raise_on_missing_callback_actions = true
7073

7174
# Required default host to link to!
7275
config.action_mailer.default_url_options = { host: 'localhost:3000' }

config/environments/production.rb

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Settings specified here will take precedence over those in config/application.rb.
55

66
# Code is not reloaded between requests.
7-
config.cache_classes = true
7+
config.enable_reloading = false
88

99
# Eager load code on boot. This eager loads most of Rails and
1010
# your application in memory, allowing both threaded web servers
@@ -13,15 +13,14 @@
1313
config.eager_load = true
1414

1515
# Full error reports are disabled and caching is turned on.
16-
config.consider_all_requests_local = false
16+
config.consider_all_requests_local = false
1717
config.action_controller.perform_caching = true
1818

19-
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20-
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
19+
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
20+
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
2121
# config.require_master_key = true
2222

23-
# Disable serving static files from the `/public` folder by default since
24-
# Apache or NGINX already handles this.
23+
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
2524
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
2625

2726
# Compress CSS using a preprocessor.
@@ -30,7 +29,7 @@
3029
# Compress JS using a preprocessor.
3130
config.assets.js_compressor = :terser
3231

33-
# Do not fallback to assets pipeline if a precompiled asset is missed.
32+
# Do not fall back to assets pipeline if a precompiled asset is missed.
3433
config.assets.compile = false
3534

3635
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
@@ -43,21 +42,31 @@
4342
# Store uploaded files on the local file system (see config/storage.yml for options).
4443
config.active_storage.service = :local
4544

45+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
46+
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
47+
# config.assume_ssl = true
48+
4649
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
4750
# config.force_ssl = true
4851

49-
# Include generic and useful information about system operation, but avoid logging too much
50-
# information to avoid inadvertent exposure of personally identifiable information (PII).
51-
config.log_level = ENV.fetch("RAILS_LOG_LEVEL") { "info" }
52+
# Log to STDOUT by default
53+
config.logger = ActiveSupport::Logger.new(STDOUT)
54+
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
55+
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
5256

5357
# Prepend all log lines with the following tags.
5458
config.log_tags = [ :request_id ]
5559

60+
# "info" includes generic and useful information about system operation, but avoids logging too much
61+
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
62+
# want to log everything, set the level to "debug".
63+
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
64+
5665
# Use a different cache store in production.
5766
# config.cache_store = :mem_cache_store
5867

5968
# Use a real queuing backend for Active Job (and separate queues per environment).
60-
# config.active_job.queue_adapter = :resque
69+
# config.active_job.queue_adapter = :resque
6170
# config.active_job.queue_name_prefix = "planner_#{Rails.env}"
6271

6372
config.action_mailer.perform_caching = false
@@ -73,28 +82,17 @@
7382
# Don't log any deprecations.
7483
config.active_support.report_deprecations = false
7584

76-
# Use default logging formatter so that PID and timestamp are not suppressed.
77-
config.log_formatter = ::Logger::Formatter.new
78-
79-
# Use a different logger for distributed setups.
80-
# require "syslog/logger"
81-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
82-
83-
if ENV["RAILS_LOG_TO_STDOUT"].present?
84-
logger = ActiveSupport::Logger.new(STDOUT)
85-
logger.formatter = config.log_formatter
86-
config.logger = ActiveSupport::TaggedLogging.new(logger)
87-
end
88-
8985
# Do not dump schema after migrations.
9086
config.active_record.dump_schema_after_migration = false
9187

92-
# Required default host to link to!
93-
config.action_mailer.default_url_options = { host: 'codebar.io' }
88+
# Enable DNS rebinding protection and other `Host` header attacks.
89+
# config.hosts = [
90+
# "example.com", # Allow requests from example.com
91+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
92+
# ]
9493

95-
# Ignore bad email addresses and do not raise email delivery errors.
96-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
97-
# config.action_mailer.raise_delivery_errors = false
94+
# Skip DNS rebinding protection for the default health check endpoint.
95+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
9896

9997
config.action_mailer.smtp_settings = {
10098
port: '587',
@@ -106,4 +104,5 @@
106104
enable_starttls_auto: true
107105
}
108106
ActionMailer::Base.delivery_method = :smtp
109-
end
107+
config.action_mailer.default_url_options = { host: 'codebar.io' }
108+
end

config/environments/test.rb

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
Rails.application.configure do
1010
# Settings specified here will take precedence over those in config/application.rb.
1111

12-
# Turn false under Spring and add config.action_view.cache_template_loading = true.
13-
config.cache_classes = true
12+
# While tests run files are not watched, reloading is not necessary.
13+
config.enable_reloading = false
1414

15-
# Eager loading loads your whole application. When running a single test locally,
16-
# this probably isn't necessary. It's a good idea to do in a continuous integration
17-
# system, or in some way before deploying your code.
15+
# Eager loading loads your entire application. When running a single test locally,
16+
# this is usually not necessary, and can slow down your test suite. However, it's
17+
# recommended that you enable it in continuous integration systems to ensure eager
18+
# loading is working properly before deploying your code.
1819
config.eager_load = ENV["CI"].present?
1920

2021
# Configure public file server for tests with Cache-Control for performance.
@@ -24,12 +25,12 @@
2425
}
2526

2627
# Show full error reports and disable caching.
27-
config.consider_all_requests_local = true
28+
config.consider_all_requests_local = true
2829
config.action_controller.perform_caching = false
2930
config.cache_store = :null_store
3031

31-
# Raise exceptions instead of rendering exception templates.
32-
config.action_dispatch.show_exceptions = false
32+
# Render exception templates for rescuable exceptions and raise for other exceptions.
33+
config.action_dispatch.show_exceptions = :rescuable
3334

3435
# Disable request forgery protection in test environment.
3536
config.action_controller.allow_forgery_protection = false
@@ -59,18 +60,15 @@
5960
# Annotate rendered view with file names.
6061
# config.action_view.annotate_rendered_view_with_filenames = true
6162

62-
# Required default host to link to!
63-
config.action_mailer.default_url_options = { host: 'localhost:3000' }
63+
# Raise error when a before_action's only/except options reference missing actions
64+
config.action_controller.raise_on_missing_callback_actions = true
6465

65-
# Configure static asset server for tests with Cache-Control for performance.
66-
config.serve_static_files = true
67-
config.static_cache_control = 'public, max-age=3600'
66+
config.action_mailer.default_url_options = { host: 'localhost:3000' }
6867

6968
# Fake omniauth for testing
7069
OmniAuth.config.test_mode = true
7170

7271
config.after_initialize do
73-
# TODO: re-enable and go through failures
7472
Bullet.enable = true
7573
Bullet.bullet_logger = true
7674
Bullet.raise = false # raise an error if n+1 query occurs

config/initializers/content_security_policy.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# # policy.report_uri "/csp-violation-report-endpoint"
1717
# end
1818
#
19-
# # Generate session nonces for permitted importmap and inline scripts
19+
# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
2020
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21-
# config.content_security_policy_nonce_directives = %w(script-src)
21+
# config.content_security_policy_nonce_directives = %w(script-src style-src)
2222
#
2323
# # Report violations without enforcing the policy.
2424
# # config.content_security_policy_report_only = true
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Be sure to restart your server when you modify this file.
22

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.
3+
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
4+
# Use this to limit dissemination of sensitive information.
5+
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
66
Rails.application.config.filter_parameters += [
77
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
88
]

config/initializers/inflections.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# are locale specific, and you may define rules for as many different
55
# locales as you wish. All of these examples are active by default:
66
# 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"
1010
# inflect.uncountable %w( fish sheep )
1111
# end
1212

1313
# These inflection rules are supported but not enabled by default:
1414
# ActiveSupport::Inflector.inflections(:en) do |inflect|
15-
# inflect.acronym 'RESTful'
15+
# inflect.acronym "RESTful"
1616
# end

0 commit comments

Comments
 (0)