Upgrade to Rails 7.1 and apply new framework defaults
* Remove deprecated options from environments * Remove deprecation warnings for upcoming Rails 7.2 * Dump schema with new defaults * Remove outdated (and erroneous) data attribute in view * Resolve a `NoMethodError` for seeds_spec.rb
This commit is contained in:
@ -14,7 +14,12 @@ require_relative '../lib/middleware/web_socket_sentry_headers'
|
||||
module CodeOcean
|
||||
class Application < Rails::Application
|
||||
# Initialize configuration defaults for originally generated Rails version.
|
||||
config.load_defaults 7.0
|
||||
config.load_defaults 7.1
|
||||
|
||||
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
||||
# not contain `.rb` files, or that should not be reloaded or eager loaded.
|
||||
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
||||
config.autoload_lib(ignore: %w[assets tasks templates generators middleware])
|
||||
|
||||
# Configuration for the application, engines, and railties goes here.
|
||||
#
|
||||
@ -30,17 +35,6 @@ module CodeOcean
|
||||
# config.i18n.default_locale = :de
|
||||
config.i18n.available_locales = %i[de en]
|
||||
|
||||
extra_paths = [
|
||||
Rails.root.join('lib'),
|
||||
]
|
||||
|
||||
# Add generators, they don't have a module structure that matches their directory structure.
|
||||
extra_paths << Rails.root.join('lib/generators')
|
||||
|
||||
config.add_autoload_paths_to_load_path = false
|
||||
config.autoload_paths += extra_paths
|
||||
config.eager_load_paths += extra_paths
|
||||
|
||||
config.relative_url_root = ENV.fetch('RAILS_RELATIVE_URL_ROOT', '/').to_s
|
||||
|
||||
config.action_cable.mount_path = "#{ENV.fetch('RAILS_RELATIVE_URL_ROOT', '')}/cable"
|
||||
|
@ -11,7 +11,7 @@ Rails.application.configure do
|
||||
# In the development environment your application's code is reloaded any time
|
||||
# it changes. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
config.cache_classes = false
|
||||
config.enable_reloading = true
|
||||
|
||||
# Eager load code for prometheus exporter
|
||||
config.eager_load = true
|
||||
@ -61,6 +61,9 @@ Rails.application.configure do
|
||||
# Highlight code that triggered database queries in logs.
|
||||
config.active_record.verbose_query_logs = true
|
||||
|
||||
# Highlight code that enqueued background job in logs.
|
||||
config.active_job.verbose_enqueue_logs = true
|
||||
|
||||
# Debug mode disables concatenation and preprocessing of assets.
|
||||
# This option may cause significant delays in view rendering with a large
|
||||
# number of complex assets.
|
||||
@ -85,4 +88,7 @@ Rails.application.configure do
|
||||
|
||||
# Uncomment if you wish to allow Action Cable access from any origin.
|
||||
# config.action_cable.disable_request_forgery_protection = true
|
||||
|
||||
# Raise error when a before_action's only/except options reference missing actions
|
||||
config.action_controller.raise_on_missing_callback_actions = true
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Code is not reloaded between requests.
|
||||
config.cache_classes = true
|
||||
config.enable_reloading = false
|
||||
|
||||
# Eager load code on boot. This eager loads most of Rails and
|
||||
# your application in memory, allowing both threaded web servers
|
||||
@ -19,10 +19,9 @@ Rails.application.configure do
|
||||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
||||
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
||||
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
|
||||
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
|
||||
# config.require_master_key = true
|
||||
config.read_encrypted_secrets = true
|
||||
|
||||
# Disable serving static files from the `/public` folder by default since
|
||||
# Apache or NGINX already handles this.
|
||||
@ -52,16 +51,28 @@ Rails.application.configure do
|
||||
# config.action_cable.url = 'wss://example.com/cable'
|
||||
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
||||
|
||||
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
|
||||
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
|
||||
config.assume_ssl = true
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
config.force_ssl = true
|
||||
config.ssl_options = {hsts: {preload: true}}
|
||||
|
||||
# Include generic and useful information about system operation, but avoid logging too much
|
||||
# information to avoid inadvertent exposure of personally identifiable information (PII).
|
||||
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info').to_sym
|
||||
if ENV['RAILS_LOG_TO_STDOUT'].present?
|
||||
# Log to STDOUT by default
|
||||
config.logger = ActiveSupport::Logger.new($stdout)
|
||||
.tap {|logger| logger.formatter = Logger::Formatter.new }
|
||||
.then {|logger| ActiveSupport::TaggedLogging.new(logger) }
|
||||
end
|
||||
|
||||
# Prepend all log lines with the following tags.
|
||||
# config.log_tags = [ :subdomain, :uuid, :request_id ]
|
||||
config.log_tags = [:request_id]
|
||||
|
||||
# Info include generic and useful information about system operation, but avoids logging too much
|
||||
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
|
||||
# want to log everything, set the level to "debug".
|
||||
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
@ -80,22 +91,17 @@ Rails.application.configure do
|
||||
# the I18n.default_locale when a translation cannot be found).
|
||||
config.i18n.fallbacks = true
|
||||
|
||||
# Send deprecation notices to registered listeners.
|
||||
config.active_support.deprecation = :notify
|
||||
|
||||
# Use default logging formatter so that PID and timestamp are not suppressed.
|
||||
config.log_formatter = Logger::Formatter.new
|
||||
|
||||
# Use a different logger for distributed setups.
|
||||
# require 'syslog/logger'
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
||||
|
||||
if ENV['RAILS_LOG_TO_STDOUT'].present?
|
||||
logger = ActiveSupport::Logger.new($stdout)
|
||||
logger.formatter = config.log_formatter
|
||||
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
||||
end
|
||||
# Don't log any deprecations.
|
||||
config.active_support.report_deprecations = false
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
# Enable DNS rebinding protection and other `Host` header attacks.
|
||||
# config.hosts = [
|
||||
# "example.com", # Allow requests from example.com
|
||||
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
||||
# ]
|
||||
# Skip DNS rebinding protection for the default health check endpoint.
|
||||
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
||||
end
|
||||
|
@ -10,13 +10,13 @@ require 'active_support/core_ext/integer/time'
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Turn false under Spring and add config.action_view.cache_template_loading = true.
|
||||
config.cache_classes = true
|
||||
# While tests run files are not watched, reloading is not necessary.
|
||||
config.enable_reloading = false
|
||||
|
||||
# Eager loading loads your whole application. When running a single test locally,
|
||||
# this probably isn't necessary. It's a good idea to do in a continuous integration
|
||||
# system, or in some way before deploying your code.
|
||||
# Eager load code for prometheus exporter
|
||||
# Eager loading loads your entire application. When running a single test locally,
|
||||
# this is usually not necessary, and can slow down your test suite. However, it's
|
||||
# recommended that you enable it in continuous integration systems to ensure eager
|
||||
# loading is working properly before deploying your code.
|
||||
config.eager_load = true
|
||||
|
||||
# Configure public file server for tests with Cache-Control for performance.
|
||||
@ -31,7 +31,7 @@ Rails.application.configure do
|
||||
config.cache_store = :memory_store
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
config.action_dispatch.show_exceptions = :rescuable
|
||||
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
@ -63,4 +63,7 @@ Rails.application.configure do
|
||||
|
||||
# Annotate rendered view with file names.
|
||||
config.action_view.annotate_rendered_view_with_filenames = true
|
||||
|
||||
# Raise error when a before_action's only/except options reference missing actions
|
||||
config.action_controller.raise_on_missing_callback_actions = true
|
||||
end
|
||||
|
@ -68,10 +68,10 @@ Rails.application.configure do
|
||||
CSP.apply_sentry_settings_for policy if SentryJavascript.active?
|
||||
end
|
||||
|
||||
# Generate session nonces for permitted importmap and inline scripts
|
||||
# Generate session nonces for permitted importmap, inline scripts, and inline styles.
|
||||
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
|
||||
# config.content_security_policy_nonce_directives = %w[script-src]
|
||||
# config.content_security_policy_nonce_directives = %w[script-src style-src]
|
||||
|
||||
# Report violations without enforcing the policy
|
||||
# Report violations without enforcing the policy.
|
||||
# config.content_security_policy_report_only = true
|
||||
end
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Configure parameters to be filtered from the log file. Use this to limit dissemination of
|
||||
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
|
||||
# notations and behaviors.
|
||||
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
|
||||
# Use this to limit dissemination of sensitive information.
|
||||
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
|
||||
Rails.application.config.filter_parameters += %i[
|
||||
passw secret token _key crypt salt certificate otp ssn
|
||||
]
|
||||
|
@ -17,3 +17,11 @@ module WillPaginate
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Temporary required for Rails 7.1+ and Slim 5.1+.
|
||||
# TODO: No GitHub issue yet
|
||||
module ActionView
|
||||
class OutputBuffer
|
||||
alias + concat
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Define an application-wide HTTP permissions policy. For further
|
||||
# information see https://developers.google.com/web/updates/2018/06/feature-policy
|
||||
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
|
||||
# TODO: Feature-Policy has been renamed to Permissions-Policy. The Permissions-Policy is
|
||||
# not yet supported by Rails (even though the new name is already used for the method)
|
||||
Rails.application.config.permissions_policy do |policy|
|
||||
@ -19,8 +21,5 @@ Rails.application.config.permissions_policy do |policy|
|
||||
policy.payment :none
|
||||
policy.picture_in_picture :none
|
||||
# The `speaker` directive is used for selection of non-default audio output devices
|
||||
policy.speaker :none
|
||||
policy.usb :none
|
||||
policy.vibrate :none
|
||||
policy.vr :none
|
||||
end
|
||||
|
Reference in New Issue
Block a user