Skip to content

Commit 667bddf

Browse files
committed
Update Rails 7.2 files
1 parent d91e3db commit 667bddf

15 files changed

+205
-57
lines changed

bin/brakeman

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env ruby
2+
require "rubygems"
3+
require "bundler/setup"
4+
5+
ARGV.unshift("--ensure-latest")
6+
7+
load Gem.bin_path("brakeman", "brakeman")

bin/setup

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

4-
# path to your application root.
54
APP_ROOT = File.expand_path("..", __dir__)
5+
APP_NAME = "reviewers"
66

77
def system!(*args)
88
system(*args, exception: true)
@@ -30,4 +30,8 @@ FileUtils.chdir APP_ROOT do
3030

3131
puts "\n== Restarting application server =="
3232
system! "bin/rails restart"
33+
34+
# puts "\n== Configuring puma-dev =="
35+
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
36+
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
3337
end

config/application.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ class Application < Rails::Application
1212

1313
# Initialize configuration defaults for originally generated Rails version.
1414
config.load_defaults 7.1
15+
config.load_defaults 7.2
1516

1617
# Please, add to the `ignore` list any other `lib` subdirectories that do
1718
# not contain `.rb` files, or that should not be reloaded or eager loaded.
1819
# Common ones are `templates`, `generators`, or `middleware`, for example.
19-
config.autoload_lib(ignore: %w(assets tasks))
20+
config.autoload_lib(ignore: %w[assets tasks])
2021

2122
# Configuration for the application, engines, and railties goes here.
2223
#

config/environments/development.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Show full error reports.
1515
config.consider_all_requests_local = true
1616

17-
# Enable server timing
17+
# Enable server timing.
1818
config.server_timing = true
1919

2020
# Enable/disable caching. By default caching is disabled.
@@ -24,9 +24,7 @@
2424
config.action_controller.enable_fragment_cache_logging = true
2525

2626
config.cache_store = :memory_store
27-
config.public_file_server.headers = {
28-
"Cache-Control" => "public, max-age=#{2.days.to_i}"
29-
}
27+
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
3028
else
3129
config.action_controller.perform_caching = false
3230

@@ -39,8 +37,12 @@
3937
# Don't care if the mailer can't send.
4038
config.action_mailer.raise_delivery_errors = false
4139

40+
# Disable caching for Action Mailer templates even if Action Controller
41+
# caching is enabled.
4242
config.action_mailer.perform_caching = false
4343

44+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
45+
4446
# Print deprecation notices to the Rails logger.
4547
config.active_support.deprecation = :log
4648

@@ -66,11 +68,14 @@
6668
# config.i18n.raise_on_missing_translations = true
6769

6870
# Annotate rendered view with file names.
69-
# config.action_view.annotate_rendered_view_with_filenames = true
71+
config.action_view.annotate_rendered_view_with_filenames = true
7072

7173
# Uncomment if you wish to allow Action Cable access from any origin.
7274
# config.action_cable.disable_request_forgery_protection = true
7375

74-
# Raise error when a before_action's only/except options reference missing actions
76+
# Raise error when a before_action's only/except options reference missing actions.
7577
config.action_controller.raise_on_missing_callback_actions = true
78+
79+
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
80+
# config.generators.apply_rubocop_autocorrect_after_generate!
7681
end

config/environments/production.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
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

1919
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
2020
# 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-
# Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it).
24-
config.public_file_server.enabled = true
23+
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
24+
# config.public_file_server.enabled = false
2525

2626
# Compress CSS using a preprocessor.
2727
# config.assets.css_compressor = :sass
2828

29-
# Do not fallback to assets pipeline if a precompiled asset is missed.
29+
# Do not fall back to assets pipeline if a precompiled asset is missed.
3030
config.assets.compile = false
3131

3232
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
@@ -51,6 +51,9 @@
5151
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
5252
config.force_ssl = true
5353

54+
# Skip http-to-https redirect for the default health check endpoint.
55+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
56+
5457
# Log to STDOUT by default
5558
config.logger = ActiveSupport::Logger.new(STDOUT)
5659
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
@@ -59,7 +62,7 @@
5962
# Prepend all log lines with the following tags.
6063
config.log_tags = [ :request_id ]
6164

62-
# Info include generic and useful information about system operation, but avoids logging too much
65+
# "info" includes generic and useful information about system operation, but avoids logging too much
6366
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
6467
# want to log everything, set the level to "debug".
6568
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
@@ -68,9 +71,11 @@
6871
# config.cache_store = :mem_cache_store
6972

7073
# Use a real queuing backend for Active Job (and separate queues per environment).
71-
# config.active_job.queue_adapter = :resque
74+
# config.active_job.queue_adapter = :resque
7275
# config.active_job.queue_name_prefix = "reviewers_production"
7376

77+
# Disable caching for Action Mailer templates even if Action Controller
78+
# caching is enabled.
7479
config.action_mailer.perform_caching = false
7580

7681
# Ignore bad email addresses and do not raise email delivery errors.
@@ -94,4 +99,8 @@
9499
# ]
95100
# Skip DNS rebinding protection for the default health check endpoint.
96101
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
102+
103+
# Enables YJIT as of Ruby 3.3, to bring sizeable performance improvements. If you are
104+
# deploying to a memory constrained environment you may want to set this to `false`.
105+
config.yjit = false
97106
end

config/environments/test.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919

2020
# Configure public file server for tests with Cache-Control for performance.
2121
config.public_file_server.enabled = true
22-
config.public_file_server.headers = {
23-
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
24-
}
22+
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
2523

2624
# Show full error reports and disable caching.
27-
config.consider_all_requests_local = true
25+
config.consider_all_requests_local = true
2826
config.action_controller.perform_caching = false
2927
config.cache_store = :null_store
3028

29+
# Render exception templates for rescuable exceptions and raise for other exceptions.
30+
# config.action_dispatch.show_exceptions = :rescuable
3131
# Raise exceptions instead of rendering exception templates.
3232
config.action_dispatch.show_exceptions = :none
3333

@@ -37,13 +37,19 @@
3737
# Store uploaded files on the local file system in a temporary directory.
3838
config.active_storage.service = :test
3939

40+
# Disable caching for Action Mailer templates even if Action Controller
41+
# caching is enabled.
4042
config.action_mailer.perform_caching = false
4143

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

49+
# Unlike controllers, the mailer instance doesn't have any context about the
50+
# incoming request so you'll need to provide the :host parameter yourself.
51+
config.action_mailer.default_url_options = { host: "www.example.com" }
52+
4753
# Print deprecation notices to the stderr.
4854
config.active_support.deprecation = :stderr
4955

@@ -59,6 +65,6 @@
5965
# Annotate rendered view with file names.
6066
# config.action_view.annotate_rendered_view_with_filenames = true
6167

62-
# Raise error when a before_action's only/except options reference missing actions
68+
# Raise error when a before_action's only/except options reference missing actions.
6369
config.action_controller.raise_on_missing_callback_actions = true
6470
end
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 partially matched (e.g. passw matches password) and filtered from the log file.
4-
# Use this to limit dissemination of sensitive information.
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.
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
]

config/puma.rb

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,33 @@
1-
# Puma can serve each request in a thread from an internal thread pool.
2-
# The `threads` method setting takes two numbers: a minimum and maximum.
3-
# Any libraries that use thread pools should be configured to match
4-
# the maximum value specified for Puma. Default is set to 5 threads for minimum
5-
# and maximum; this matches the default thread size of Active Record.
6-
#
7-
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 3 }
8-
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9-
threads min_threads_count, max_threads_count
1+
# This configuration file will be evaluated by Puma. The top-level methods that
2+
# are invoked here are part of Puma's configuration DSL. For more information
3+
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
104

11-
# Specifies the `worker_timeout` threshold that Puma will use to wait before
12-
# terminating a worker in development environments.
5+
# Puma starts a configurable number of processes (workers) and each process
6+
# serves each request in a thread from an internal thread pool.
137
#
14-
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15-
16-
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
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.
1711
#
18-
port ENV.fetch("PORT") { 3000 }
19-
20-
# Specifies the `environment` that Puma will run in.
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.
2116
#
22-
environment ENV.fetch("RAILS_ENV") { "development" }
23-
24-
# Specifies the `pidfile` that Puma will use.
25-
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26-
27-
# Specifies the number of `workers` to boot in clustered mode.
28-
# Workers are forked web server processes. If using threads and workers together
29-
# the concurrency of the application would be max `threads` * `workers`.
30-
# Workers do not work on JRuby or Windows (both of which do not support
31-
# processes).
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.
3219
#
33-
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
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
3425

35-
# Use the `preload_app!` method when specifying a `workers` number.
36-
# This directive tells Puma to first boot the application and load code
37-
# before forking the application. This takes advantage of Copy On Write
38-
# process behavior so workers use less memory.
39-
#
40-
# preload_app!
26+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
27+
port ENV.fetch("PORT", 3000)
4128

4229
# Allow puma to be restarted by `bin/rails restart` command.
4330
plugin :tmp_restart
31+
32+
# Only use a pidfile when requested
33+
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
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This migration comes from active_storage (originally 20211119233751)
2+
class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
3+
def change
4+
return unless table_exists?(:active_storage_blobs)
5+
6+
change_column_null(:active_storage_blobs, :checksum, true)
7+
end
8+
end

db/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.0].define(version: 2023_05_15_114824) do
13+
ActiveRecord::Schema[7.2].define(version: 2024_08_11_085126) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "plpgsql"
1616

0 commit comments

Comments
 (0)