Update to Rails 7.1 #8

Merged
atomaka merged 5 commits from rails-71 into main 2023-10-10 23:01:16 -04:00
6 changed files with 20 additions and 19 deletions
Showing only changes of commit 3ae931074b - Show all commits

View file

@ -14,7 +14,7 @@ module FamilyBudget
# Please, add to the `ignore` list any other `lib` subdirectories that do # 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. # not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example. # Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w(assets tasks)) config.autoload_lib(ignore: %w[assets tasks])
# Configuration for the application, engines, and railties goes here. # Configuration for the application, engines, and railties goes here.
# #

View file

@ -13,7 +13,7 @@ Rails.application.configure do
config.eager_load = true config.eager_load = true
# Full error reports are disabled and caching is turned on. # Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false config.consider_all_requests_local = false
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
@ -52,12 +52,12 @@ Rails.application.configure do
config.force_ssl = true config.force_ssl = true
# Log to STDOUT by default # Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT) config.logger = ActiveSupport::Logger.new($stdout)
.tap { |logger| logger.formatter = ::Logger::Formatter.new } .tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) } .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
# Prepend all log lines with the following tags. # Prepend all log lines with the following tags.
config.log_tags = [ :request_id ] config.log_tags = [:request_id]
# Info include generic and useful information about system operation, but avoids logging too much # 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 # information to avoid inadvertent exposure of personally identifiable information (PII). If you

View file

@ -24,7 +24,7 @@ Rails.application.configure do
} }
# Show full error reports and disable caching. # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
config.cache_store = :null_store config.cache_store = :null_store

View file

@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. # 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. # Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [ Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn

View file

@ -6,7 +6,7 @@ class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
unless column_exists?(:active_storage_blobs, :service_name) unless column_exists?(:active_storage_blobs, :service_name)
add_column :active_storage_blobs, :service_name, :string add_column :active_storage_blobs, :service_name, :string
if configured_service = ActiveStorage::Blob.service.name if (configured_service = ActiveStorage::Blob.service.name)
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
end end

View file

@ -8,20 +8,21 @@ class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
t.string :variation_digest, null: false t.string :variation_digest, null: false
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true t.index %i[blob_id variation_digest], name: "index_active_storage_variant_records_uniqueness", unique: true
t.foreign_key :active_storage_blobs, column: :blob_id t.foreign_key :active_storage_blobs, column: :blob_id
end end
end end
private private
def primary_key_type
config = Rails.configuration.generators
config.options[config.orm][:primary_key_type] || :primary_key
end
def blobs_primary_key_type def primary_key_type
pkey_name = connection.primary_key(:active_storage_blobs) config = Rails.configuration.generators
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } config.options[config.orm][:primary_key_type] || :primary_key
pkey_column.bigint? ? :bigint : pkey_column.type end
end
def blobs_primary_key_type
pkey_name = connection.primary_key(:active_storage_blobs)
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
pkey_column.bigint? ? :bigint : pkey_column.type
end
end end