From 8b825522a36b30f503d67d29998fcbf2a68a038e Mon Sep 17 00:00:00 2001 From: Ryo Takaishi Date: Thu, 2 Jan 2025 10:12:52 +0900 Subject: [PATCH 1/7] enable new framework defaults 7.0 --- config/application.rb | 2 +- config/environments/development.rb | 3 + config/environments/production.rb | 23 +--- .../initializers/content_security_policy.rb | 9 +- config/initializers/cors.rb | 7 ++ .../initializers/filter_parameter_logging.rb | 4 +- .../new_framework_defaults_7_0.rb | 117 ------------------ ..._to_active_storage_blobs.active_storage.rb | 22 ++++ ..._storage_variant_records.active_storage.rb | 27 ++++ ...e_storage_blobs_checksum.active_storage.rb | 8 ++ db/schema.rb | 2 +- 11 files changed, 78 insertions(+), 146 deletions(-) delete mode 100644 config/initializers/new_framework_defaults_7_0.rb create mode 100644 db/migrate/20250102010524_add_service_name_to_active_storage_blobs.active_storage.rb create mode 100644 db/migrate/20250102010525_create_active_storage_variant_records.active_storage.rb create mode 100644 db/migrate/20250102010526_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb diff --git a/config/application.rb b/config/application.rb index 4781fe9db..555d67e9c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -13,7 +13,7 @@ module Cndtattend class Application < Rails::Application config.time_zone = 'Asia/Tokyo' # Initialize configuration defaults for originally generated Rails version. - config.load_defaults(6.1) + config.load_defaults(7.0) # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/environments/development.rb b/config/environments/development.rb index 189fc543a..f03e2672c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -82,6 +82,9 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true + config.after_initialize do Bullet.enable = true # Bulletプラグインを有効 Bullet.alert = false # JavaScriptでの通知 diff --git a/config/environments/production.rb b/config/environments/production.rb index 7cf143ba8..ef363b2b1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -79,8 +79,9 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners. + # Don't log any deprecations. config.active_support.deprecation = :notify + config.active_support.report_deprecations = false # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new @@ -98,26 +99,6 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - # Inserts middleware to perform automatic connection switching. - # The `database_selector` hash is used to pass options to the DatabaseSelector - # middleware. The `delay` is used to determine how long to wait after a write - # to send a subsequent read to the primary. - # - # The `database_resolver` class is used by the middleware to determine which - # database is appropriate to use based on the time delay. - # - # The `database_resolver_context` class is used by the middleware to set - # timestamps for the last write to the primary. The resolver uses the context - # class timestamps to determine how long to wait before reading from the - # replica. - # - # By default Rails will store a last write timestamp in the session. The - # DatabaseSelector middleware is designed as such you can define your own - # strategy for connection switching and pass that into the middleware through - # these configuration options. - # config.active_record.database_selector = { delay: 2.seconds } - # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver - # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session OmniAuth.config.on_failure = Proc.new do |env| message_key = env['omniauth.error.type'] error_description = Rack::Utils.escape(env['omniauth.error'].error_reason) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 3621f97f8..54f47cf15 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,8 +1,8 @@ # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header # Rails.application.configure do # config.content_security_policy do |policy| @@ -20,7 +20,6 @@ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } # config.content_security_policy_nonce_directives = %w(script-src) # -# # Report CSP violations to a specified URI. See: -# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true # end diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 03c5a8c6a..bba93ed27 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -1,3 +1,10 @@ +# Be sure to restart your server when you modify this file. + +# Avoid CORS issues when API is called from the frontend app. +# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. + +# Read more: https://github.com/cyu/rack-cors + Rails.application.config.middleware.insert_before(0, Rack::Cors) do allow do origins ENV['DREAMKAST_UI_BASE_URL'] || %r{https://.*\.cloudnativedays\.jp}, %r{https://emtec-intermission-git-.*-emtec\.vercel\.app}, %r{https://emtec-intermission\.vercel\.app} diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 2899da4ec..a9a173b9f 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,6 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log 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. Rails.application.config.filter_parameters += [ :password, :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb deleted file mode 100644 index a579326e2..000000000 --- a/config/initializers/new_framework_defaults_7_0.rb +++ /dev/null @@ -1,117 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.0 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `7.0`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -# `button_to` view helper will render `