diff --git a/.idea/altmedia.iml b/.idea/altmedia.iml
index 088d39d6..59b3ebfb 100644
--- a/.idea/altmedia.iml
+++ b/.idea/altmedia.iml
@@ -31,17 +31,17 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -65,7 +65,6 @@
-
@@ -159,10 +158,10 @@
-
+
-
+
@@ -216,6 +215,7 @@
+
@@ -238,9 +238,11 @@
+
+
@@ -269,10 +271,12 @@
+
+
@@ -295,9 +299,11 @@
+
+
@@ -326,10 +332,12 @@
+
+
@@ -453,9 +461,9 @@
+
-
diff --git a/.rubocop.yml b/.rubocop.yml
index 52e34b09..29690ec1 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -553,8 +553,13 @@ Rails/SelectMap: # new in 2.21
Enabled: true
Rails/StripHeredoc: # new in 2.15
Enabled: true
+
+# This changes all .require.permit to .expect, which is not always what we want.
+# For example, it means all parameters are required, which would break the
+# proxy borrower form (a middle name would be required for the researcher).
Rails/StrongParametersExpect: # new in 2.29
- Enabled: true
+ Enabled: false
+
Rails/ThreeStateBooleanColumn: # new in 2.19
Enabled: true
Rails/ToFormattedS: # new in 2.15
diff --git a/Gemfile b/Gemfile
index f112668a..d3bb23f6 100644
--- a/Gemfile
+++ b/Gemfile
@@ -31,7 +31,7 @@ gem 'omniauth-rails_csrf_protection', '~> 1.0'
gem 'pg', '~> 1.2'
gem 'prawn', '~> 2.4'
gem 'puma', '~> 4.3', '>= 4.3.12'
-gem 'rails', '~> 7.2.3'
+gem 'rails', '~> 8.0.4'
gem 'recaptcha', '~> 4.13'
gem 'sprockets', '~> 4.0'
gem 'tzinfo-data', platforms: %i[windows jruby]
diff --git a/Gemfile.lock b/Gemfile.lock
index 7d215caa..9c26dd6f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,68 +1,65 @@
GEM
remote: https://rubygems.org/
specs:
- actioncable (7.2.3)
- actionpack (= 7.2.3)
- activesupport (= 7.2.3)
+ actioncable (8.0.4)
+ actionpack (= 8.0.4)
+ activesupport (= 8.0.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
- actionmailbox (7.2.3)
- actionpack (= 7.2.3)
- activejob (= 7.2.3)
- activerecord (= 7.2.3)
- activestorage (= 7.2.3)
- activesupport (= 7.2.3)
+ actionmailbox (8.0.4)
+ actionpack (= 8.0.4)
+ activejob (= 8.0.4)
+ activerecord (= 8.0.4)
+ activestorage (= 8.0.4)
+ activesupport (= 8.0.4)
mail (>= 2.8.0)
- actionmailer (7.2.3)
- actionpack (= 7.2.3)
- actionview (= 7.2.3)
- activejob (= 7.2.3)
- activesupport (= 7.2.3)
+ actionmailer (8.0.4)
+ actionpack (= 8.0.4)
+ actionview (= 8.0.4)
+ activejob (= 8.0.4)
+ activesupport (= 8.0.4)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
- actionpack (7.2.3)
- actionview (= 7.2.3)
- activesupport (= 7.2.3)
- cgi
+ actionpack (8.0.4)
+ actionview (= 8.0.4)
+ activesupport (= 8.0.4)
nokogiri (>= 1.8.5)
- racc
- rack (>= 2.2.4, < 3.3)
+ rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
- actiontext (7.2.3)
- actionpack (= 7.2.3)
- activerecord (= 7.2.3)
- activestorage (= 7.2.3)
- activesupport (= 7.2.3)
+ actiontext (8.0.4)
+ actionpack (= 8.0.4)
+ activerecord (= 8.0.4)
+ activestorage (= 8.0.4)
+ activesupport (= 8.0.4)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
- actionview (7.2.3)
- activesupport (= 7.2.3)
+ actionview (8.0.4)
+ activesupport (= 8.0.4)
builder (~> 3.1)
- cgi
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
- activejob (7.2.3)
- activesupport (= 7.2.3)
+ activejob (8.0.4)
+ activesupport (= 8.0.4)
globalid (>= 0.3.6)
- activemodel (7.2.3)
- activesupport (= 7.2.3)
- activerecord (7.2.3)
- activemodel (= 7.2.3)
- activesupport (= 7.2.3)
+ activemodel (8.0.4)
+ activesupport (= 8.0.4)
+ activerecord (8.0.4)
+ activemodel (= 8.0.4)
+ activesupport (= 8.0.4)
timeout (>= 0.4.0)
- activestorage (7.2.3)
- actionpack (= 7.2.3)
- activejob (= 7.2.3)
- activerecord (= 7.2.3)
- activesupport (= 7.2.3)
+ activestorage (8.0.4)
+ actionpack (= 8.0.4)
+ activejob (= 8.0.4)
+ activerecord (= 8.0.4)
+ activesupport (= 8.0.4)
marcel (~> 1.0)
- activesupport (7.2.3)
+ activesupport (8.0.4)
base64
benchmark (>= 0.3)
bigdecimal
@@ -74,6 +71,7 @@ GEM
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
+ uri (>= 0.13.1)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
amazing_print (1.8.1)
@@ -144,7 +142,6 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
- cgi (0.5.1)
childprocess (4.1.0)
colorize (1.1.0)
concurrent-ruby (1.3.5)
@@ -319,20 +316,20 @@ GEM
rackup (1.0.1)
rack (< 3)
webrick
- rails (7.2.3)
- actioncable (= 7.2.3)
- actionmailbox (= 7.2.3)
- actionmailer (= 7.2.3)
- actionpack (= 7.2.3)
- actiontext (= 7.2.3)
- actionview (= 7.2.3)
- activejob (= 7.2.3)
- activemodel (= 7.2.3)
- activerecord (= 7.2.3)
- activestorage (= 7.2.3)
- activesupport (= 7.2.3)
+ rails (8.0.4)
+ actioncable (= 8.0.4)
+ actionmailbox (= 8.0.4)
+ actionmailer (= 8.0.4)
+ actionpack (= 8.0.4)
+ actiontext (= 8.0.4)
+ actionview (= 8.0.4)
+ activejob (= 8.0.4)
+ activemodel (= 8.0.4)
+ activerecord (= 8.0.4)
+ activestorage (= 8.0.4)
+ activesupport (= 8.0.4)
bundler (>= 1.15.0)
- railties (= 7.2.3)
+ railties (= 8.0.4)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
@@ -340,10 +337,9 @@ GEM
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
- railties (7.2.3)
- actionpack (= 7.2.3)
- activesupport (= 7.2.3)
- cgi
+ railties (8.0.4)
+ actionpack (= 8.0.4)
+ activesupport (= 8.0.4)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
@@ -482,6 +478,7 @@ GEM
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
+ uri (1.1.1)
useragent (0.16.11)
web-console (4.2.0)
actionview (>= 6.0.0)
@@ -543,7 +540,7 @@ DEPENDENCIES
pg (~> 1.2)
prawn (~> 2.4)
puma (~> 4.3, >= 4.3.12)
- rails (~> 7.2.3)
+ rails (~> 8.0.4)
recaptcha (~> 4.13)
roo (~> 2.8)
rspec (~> 3.13)
diff --git a/bin/dev b/bin/dev
new file mode 100755
index 00000000..5f91c205
--- /dev/null
+++ b/bin/dev
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec "./bin/rails", "server", *ARGV
diff --git a/bin/setup b/bin/setup
index 3cd5a9d7..be3db3c0 100755
--- a/bin/setup
+++ b/bin/setup
@@ -1,7 +1,6 @@
#!/usr/bin/env ruby
require "fileutils"
-# path to your application root.
APP_ROOT = File.expand_path("..", __dir__)
def system!(*args)
@@ -14,7 +13,6 @@ FileUtils.chdir APP_ROOT do
# Add necessary setup steps to this file.
puts "== Installing dependencies =="
- system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
# puts "\n== Copying sample files =="
@@ -28,6 +26,9 @@ FileUtils.chdir APP_ROOT do
puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"
- puts "\n== Restarting application server =="
- system! "bin/rails restart"
+ unless ARGV.include?("--skip-server")
+ puts "\n== Starting development server =="
+ STDOUT.flush # flush the output before exec(2) so that it displays
+ exec "bin/dev"
+ end
end
diff --git a/config/application.rb b/config/application.rb
index 7f620f6a..0a69a08f 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -51,7 +51,7 @@ def log_active_storage_root!(active_storage_root)
end
- config.load_defaults 7.2
+ config.load_defaults 8.0
# 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.
diff --git a/config/environments/development.rb b/config/environments/development.rb
index f8fcc64c..9eb84da4 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -7,9 +7,7 @@
# Allow host requests for preview environments
config.hosts << /.*\.ucblib\.org/
- # 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.
+ # Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eager load code on boot.
@@ -24,30 +22,26 @@
# Enable server timing.
config.server_timing = true
- # Enable/disable caching. By default caching is disabled.
- # Run rails dev:cache to toggle caching.
+ # Enable/disable Action Controller caching. By default Action Controller caching is disabled.
+ # Run rails dev:cache to toggle Action Controller caching.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
-
- config.cache_store = :memory_store
- config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{2.days.to_i}"
- }
+ config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" }
else
config.action_controller.perform_caching = false
-
- config.cache_store = :null_store
end
+ # Change to :null_store to avoid any caching.
+ config.cache_store = :memory_store
+
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
- # Fake sending of emails
+ # Don't care if the mailer can't send.
config.action_mailer.delivery_method = :test
- # Disable caching for Action Mailer templates even if Action Controller
- # caching is enabled.
+ # Make template changes take effect immediately.
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
@@ -65,6 +59,9 @@
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
+ # Append comments with runtime information tags to SQL queries in logs.
+ config.active_record.query_log_tags_enabled = true
+
# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true
diff --git a/config/environments/production.rb b/config/environments/production.rb
index f6a86f54..8d08ab6f 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -7,46 +7,25 @@
# Code is not reloaded between requests.
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
- # and those relying on copy on write to perform better.
- # Rake tasks automatically ignore this option for performance.
+ # Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
config.eager_load = true
- # Full error reports are disabled and caching is turned on.
+ # Full error reports are disabled.
config.consider_all_requests_local = false
- 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
- # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
- # config.require_master_key = true
- # Service static files, because we don't necessarily run nginx in front.
- config.public_file_server.enabled = true
-
- # Compress CSS using a preprocessor.
- # config.assets.css_compressor = :sass
+ # Turn on fragment caching in view templates.
+ config.action_controller.perform_caching = true
- # Do not fall back to assets pipeline if a precompiled asset is missed.
- config.assets.compile = false
+ # Cache assets for far-future expiry since they are all digest stamped.
+ config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{1.year.to_i}" }
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = 'http://assets.example.com'
- # Specifies the header that your server uses for sending files.
- # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
-
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
- # Mount Action Cable outside main process or domain.
- # config.action_cable.mount_path = nil
- # 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.
@@ -55,21 +34,14 @@
# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
- # "info" includes 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".
+ # Change to "debug" to log everything (including potentially personally-identifiable information!)
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
- # Use a different cache store in production.
+ # Replace the default in-process memory cache store with a durable alternative.
# config.cache_store = :mem_cache_store
- # Use a real queuing backend for Active Job (and separate queues per environment).
+ # Replace the default in-process and non-durable queuing backend for Active Job.
# config.active_job.queue_adapter = :resque
- # config.active_job.queue_name_prefix = "framework_production"
-
- # Disable caching for Action Mailer templates even if Action Controller
- # caching is enabled.
- config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 0af46bc6..c37996ce 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,5 +1,3 @@
-require 'active_support/core_ext/integer/time'
-
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
@@ -18,14 +16,10 @@
config.eager_load = ENV['CI'].present?
# Configure public file server for tests with Cache-Control for performance.
- config.public_file_server.enabled = true
- config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
- }
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
- # Show full error reports and disable caching.
+ # Show full error reports.
config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates.
@@ -37,10 +31,6 @@
# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test
- # Disable caching for Action Mailer templates even if Action Controller
- # caching is enabled.
- config.action_mailer.perform_caching = false
-
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
@@ -53,12 +43,6 @@
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
- # Raise exceptions for disallowed deprecations.
- config.active_support.disallowed_deprecation = :raise
-
- # Tell Active Support which deprecation messages to disallow.
- config.active_support.disallowed_deprecation_warnings = []
-
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true
diff --git a/config/puma.rb b/config/puma.rb
index b1b37118..af3ba184 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -1,10 +1,14 @@
# This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
-
+#
# Puma starts a configurable number of processes (workers) and each process
# serves each request in a thread from an internal thread pool.
#
+# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
+# should only set this value when you want to run 2 or more workers. The
+# default is already 1.
+#
# The ideal number of threads per worker depends both on how much time the
# application spends waiting for IO operations and on how much you wish to
# prioritize throughput over latency.
@@ -28,6 +32,9 @@
# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
+# Run the Solid Queue supervisor inside of Puma for single-server deployments
+plugin :solid_queue if ENV['SOLID_QUEUE_IN_PUMA']
+
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
pidfile ENV['PIDFILE'] if ENV['PIDFILE']
diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake
index b7fe33cf..bdacec58 100644
--- a/lib/tasks/db.rake
+++ b/lib/tasks/db.rake
@@ -5,8 +5,8 @@ namespace :db do
max_tries = 4
begin
pool ||= ActiveRecord::Base.establish_connection
- pool.connection
- rescue PG::ConnectionBad
+ ActiveRecord::Base.connection.verify!
+ rescue PG::ConnectionBad, ActiveRecord::DatabaseConnectionError
raise unless (tries += 1) <= max_tries
sleep_time = 2**tries # backoff exponentially (2s, 4s, 8s, ...)