Skip to content

Commit 2e817b3

Browse files
committed
Rails 7.2
1 parent 2a0fb17 commit 2e817b3

16 files changed

+179
-36
lines changed

app-rails/bin/rubocop

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ end
2424
require "rubygems"
2525
require "bundler/setup"
2626

27+
# explicit rubocop config increases performance slightly while avoiding config confusion.
28+
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
29+
2730
load Gem.bin_path("rubocop", "rubocop")

app-rails/bin/setup

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env ruby
22
require "fileutils"
33

4-
# path to your application root.
54
APP_ROOT = File.expand_path("..", __dir__)
65

76
def system!(*args)

app-rails/config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Application < Rails::Application
1717
config.i18n.load_path += Dir[Rails.root.join("config", "locales", "**", "*.{rb,yml}")]
1818

1919
# Initialize configuration defaults for originally generated Rails version.
20-
config.load_defaults 7.1
20+
config.load_defaults 7.2
2121

2222
# Please, add to the `ignore` list any other `lib` subdirectories that do
2323
# not contain `.rb` files, or that should not be reloaded or eager loaded.

app-rails/config/environments/development.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Show full error reports.
1818
config.consider_all_requests_local = true
1919

20-
# Enable server timing
20+
# Enable server timing.
2121
config.server_timing = true
2222

2323
# Enable/disable caching. By default caching is disabled.
@@ -43,8 +43,12 @@
4343
# Don't care if the mailer can't send.
4444
config.action_mailer.raise_delivery_errors = false
4545

46+
# Disable caching for Action Mailer templates even if Action Controller
47+
# caching is enabled.
4648
config.action_mailer.perform_caching = false
4749

50+
config.action_mailer.default_url_options = { host: "localhost", port: 3100 }
51+
4852
# Print deprecation notices to the Rails logger.
4953
config.active_support.deprecation = :log
5054

@@ -73,11 +77,14 @@
7377
# config.i18n.raise_on_missing_translations = true
7478

7579
# Annotate rendered view with file names.
76-
# config.action_view.annotate_rendered_view_with_filenames = true
80+
config.action_view.annotate_rendered_view_with_filenames = true
7781

7882
# Uncomment if you wish to allow Action Cable access from any origin.
7983
# config.action_cable.disable_request_forgery_protection = true
8084

81-
# Raise error when a before_action's only/except options reference missing actions
85+
# Raise error when a before_action's only/except options reference missing actions.
8286
# config.action_controller.raise_on_missing_callback_actions = true
87+
88+
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
89+
# config.generators.apply_rubocop_autocorrect_after_generate!
8390
end

app-rails/config/environments/production.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@
8181
# config.active_job.queue_adapter = :resque
8282
# config.active_job.queue_name_prefix = "app-rails:production"
8383

84-
config.action_mailer.delivery_method = :sesv2
84+
# Disable caching for Action Mailer templates even if Action Controller
85+
# caching is enabled.
8586
config.action_mailer.perform_caching = false
8687

88+
config.action_mailer.delivery_method = :sesv2
89+
8790
# Ignore bad email addresses and do not raise email delivery errors.
8891
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
8992
# config.action_mailer.raise_delivery_errors = false
@@ -98,6 +101,9 @@
98101
# Do not dump schema after migrations.
99102
config.active_record.dump_schema_after_migration = false
100103

104+
# Only use :id for inspections in production.
105+
config.active_record.attributes_for_inspect = [ :id ]
106+
101107
# Enable DNS rebinding protection and other `Host` header attacks.
102108
# config.hosts = [
103109
# "example.com", # Allow requests from example.com

app-rails/config/environments/test.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@
4040
# Store uploaded files on the local file system in a temporary directory.
4141
config.active_storage.service = :test
4242

43+
# Disable caching for Action Mailer templates even if Action Controller
44+
# caching is enabled.
4345
config.action_mailer.perform_caching = false
4446

4547
# Tell Action Mailer not to deliver emails to the real world.
4648
# The :test delivery method accumulates sent emails in the
4749
# ActionMailer::Base.deliveries array.
4850
config.action_mailer.delivery_method = :test
4951

52+
# Unlike controllers, the mailer instance doesn't have any context about the
53+
# incoming request so you'll need to provide the :host parameter yourself.
54+
config.action_mailer.default_url_options = { host: "localhost", port: 3100 }
55+
5056
# Print deprecation notices to the stderr.
5157
config.active_support.deprecation = :stderr
5258

@@ -62,6 +68,6 @@
6268
# Annotate rendered view with file names.
6369
# config.action_view.annotate_rendered_view_with_filenames = true
6470

65-
# Raise error when a before_action's only/except options reference missing actions
71+
# Raise error when a before_action's only/except options reference missing actions.
6672
# config.action_controller.raise_on_missing_callback_actions = true
6773
end

app-rails/config/initializers/filter_parameter_logging.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# Use this to limit dissemination of sensitive information.
55
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
66
Rails.application.config.filter_parameters += [
7-
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
7+
:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
88
]

app-rails/config/puma.rb

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,33 @@
22
# are invoked here are part of Puma's configuration DSL. For more information
33
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
44

5-
# Puma can serve each request in a thread from an internal thread pool.
6-
# The `threads` method setting takes two numbers: a minimum and maximum.
7-
# Any libraries that use thread pools should be configured to match
8-
# the maximum value specified for Puma. Default is set to 5 threads for minimum
9-
# and maximum; this matches the default thread size of Active Record.
10-
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
11-
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
12-
threads min_threads_count, max_threads_count
5+
# Puma starts a configurable number of processes (workers) and each process
6+
# serves each request in a thread from an internal thread pool.
7+
#
8+
# The ideal number of threads per worker depends both on how much time the
9+
# application spends waiting for IO operations and on how much you wish to
10+
# to prioritize throughput over latency.
11+
#
12+
# As a rule of thumb, increasing the number of threads will increase how much
13+
# traffic a given process can handle (throughput), but due to CRuby's
14+
# Global VM Lock (GVL) it has diminishing returns and will degrade the
15+
# response time (latency) of the application.
16+
#
17+
# The default is set to 3 threads as it's deemed a decent compromise between
18+
# throughput and latency for the average Rails application.
19+
#
20+
# Any libraries that use a connection pool or another resource pool should
21+
# be configured to provide at least as many connections as the number of
22+
# threads. This includes Active Record's `pool` parameter in `database.yml`.
23+
threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
24+
threads threads_count, threads_count
1325

14-
# Specifies that the worker count should equal the number of processors in production.
15-
if ENV["RAILS_ENV"] == "production"
16-
require "concurrent-ruby"
17-
worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
18-
workers worker_count if worker_count > 1
19-
end
20-
21-
# Specifies the `worker_timeout` threshold that Puma will use to wait before
22-
# terminating a worker in development environments.
23-
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
24-
25-
# Specifies the `port` that Puma will listen on to receive requests; default is 3100.
26-
port ENV.fetch("PORT") { 3100 }
27-
28-
# Specifies the `environment` that Puma will run in.
29-
environment ENV.fetch("RAILS_ENV") { "development" }
30-
31-
# Specifies the `pidfile` that Puma will use.
32-
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
27+
port ENV.fetch("PORT", 3100)
3328

3429
# Allow puma to be restarted by `bin/rails restart` command.
3530
plugin :tmp_restart
31+
32+
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
33+
# In other environments, only set the PID file if requested.
34+
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This migration comes from active_storage (originally 20190112182829)
2+
class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
3+
def up
4+
return unless table_exists?(:active_storage_blobs)
5+
6+
unless column_exists?(:active_storage_blobs, :service_name)
7+
add_column :active_storage_blobs, :service_name, :string
8+
9+
if configured_service = ActiveStorage::Blob.service.name
10+
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
11+
end
12+
13+
change_column :active_storage_blobs, :service_name, :string, null: false
14+
end
15+
end
16+
17+
def down
18+
return unless table_exists?(:active_storage_blobs)
19+
20+
remove_column :active_storage_blobs, :service_name
21+
end
22+
end
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This migration comes from active_storage (originally 20191206030411)
2+
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
3+
def change
4+
return unless table_exists?(:active_storage_blobs)
5+
6+
# Use Active Record's configured type for primary key
7+
create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t|
8+
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
9+
t.string :variation_digest, null: false
10+
11+
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
12+
t.foreign_key :active_storage_blobs, column: :blob_id
13+
end
14+
end
15+
16+
private
17+
def primary_key_type
18+
config = Rails.configuration.generators
19+
config.options[config.orm][:primary_key_type] || :primary_key
20+
end
21+
22+
def blobs_primary_key_type
23+
pkey_name = connection.primary_key(:active_storage_blobs)
24+
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
25+
pkey_column.bigint? ? :bigint : pkey_column.type
26+
end
27+
end

0 commit comments

Comments
 (0)