Skip to content

Commit 2217de0

Browse files
committed
chore: run Rails upgrade script
1 parent 63a309e commit 2217de0

7 files changed

Lines changed: 150 additions & 135 deletions

File tree

bin/setup

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
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)
8-
system(*args) || abort("\n== Command #{args} failed ==")
7+
system(*args, exception: true)
98
end
109

1110
FileUtils.chdir APP_ROOT do
@@ -14,7 +13,6 @@ FileUtils.chdir APP_ROOT do
1413
# Add necessary setup steps to this file.
1514

1615
puts "== Installing dependencies =="
17-
system! "gem install bundler --conservative"
1816
system("bundle check") || system!("bundle install")
1917

2018
# puts "\n== Copying sample files =="
@@ -24,10 +22,14 @@ FileUtils.chdir APP_ROOT do
2422

2523
puts "\n== Preparing database =="
2624
system! "bin/rails db:prepare"
25+
system! "bin/rails db:reset" if ARGV.include?("--reset")
2726

2827
puts "\n== Removing old logs and tempfiles =="
2928
system! "bin/rails log:clear tmp:clear"
3029

31-
puts "\n== Restarting application server =="
32-
system! "bin/rails restart"
30+
unless ARGV.include?("--skip-server")
31+
puts "\n== Starting development server =="
32+
STDOUT.flush # flush the output before exec(2) so that it displays
33+
exec "bin/dev"
34+
end
3335
end

config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Application < Rails::Application
1414
config.api_only = true
1515

1616
# Initialize configuration defaults for originally generated Rails version.
17-
config.load_defaults 7.0
17+
config.load_defaults 8.1
1818

1919
# We use some Postgres features that Rails doesn't quite know about
2020
# so use the SQL dumping format

config/environments/development.rb

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,74 @@
88
# Permit hostname used in local Docker environment
99
config.hosts << "local-office-search-api.test"
1010

11-
# In the development environment your application's code is reloaded any time
12-
# it changes. This slows down response time but is perfect for development
13-
# since you don't have to restart the web server when you make code changes.
14-
config.cache_classes = false
15-
1611
# As we run in Docker, we also need to use an alternative way of watching for file changes for reloading
1712
config.file_watcher = ActiveSupport::FileUpdateChecker
1813

14+
# Make code changes take effect immediately without server restart.
15+
config.enable_reloading = true
16+
1917
# Do not eager load code on boot.
2018
config.eager_load = false
2119

2220
# Show full error reports.
2321
config.consider_all_requests_local = true
2422

25-
# Enable server timing
23+
# Enable server timing.
2624
config.server_timing = true
2725

28-
# Enable/disable caching. By default caching is disabled.
29-
# Run rails dev:cache to toggle caching.
26+
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
27+
# Run rails dev:cache to toggle Action Controller caching.
3028
if Rails.root.join("tmp/caching-dev.txt").exist?
31-
config.action_controller.perform_caching = true
32-
config.action_controller.enable_fragment_cache_logging = true
33-
34-
config.cache_store = :memory_store
35-
config.public_file_server.headers = {
36-
"Cache-Control" => "public, max-age=#{2.days.to_i}"
37-
}
29+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
3830
else
3931
config.action_controller.perform_caching = false
40-
41-
config.cache_store = :null_store
4232
end
4333

34+
# Change to :null_store to avoid any caching.
35+
config.cache_store = :memory_store
36+
4437
# Store uploaded files on the local file system (see config/storage.yml for options).
4538
config.active_storage.service = :local
4639

4740
# Don't care if the mailer can't send.
4841
config.action_mailer.raise_delivery_errors = false
4942

43+
# Make template changes take effect immediately.
5044
config.action_mailer.perform_caching = false
5145

46+
# Set localhost to be used by links generated in mailer templates.
47+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
48+
5249
# Print deprecation notices to the Rails logger.
5350
config.active_support.deprecation = :log
5451

55-
# Raise exceptions for disallowed deprecations.
56-
config.active_support.disallowed_deprecation = :raise
57-
58-
# Tell Active Support which deprecation messages to disallow.
59-
config.active_support.disallowed_deprecation_warnings = []
60-
6152
# Raise an error on page load if there are pending migrations.
6253
config.active_record.migration_error = :page_load
6354

6455
# Highlight code that triggered database queries in logs.
6556
config.active_record.verbose_query_logs = true
6657

58+
# Append comments with runtime information tags to SQL queries in logs.
59+
config.active_record.query_log_tags_enabled = true
60+
61+
# Highlight code that enqueued background job in logs.
62+
config.active_job.verbose_enqueue_logs = true
63+
64+
# Highlight code that triggered redirect in logs.
65+
config.action_dispatch.verbose_redirect_logs = true
66+
6767
# Raises error for missing translations.
6868
# config.i18n.raise_on_missing_translations = true
6969

7070
# Annotate rendered view with file names.
71-
# config.action_view.annotate_rendered_view_with_filenames = true
71+
config.action_view.annotate_rendered_view_with_filenames = true
7272

7373
# Uncomment if you wish to allow Action Cable access from any origin.
7474
# config.action_cable.disable_request_forgery_protection = true
75+
76+
# Raise error when a before_action's only/except options reference missing actions.
77+
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!
7581
end

config/environments/production.rb

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,41 @@
66
# Settings specified here will take precedence over those in config/application.rb.
77

88
# Code is not reloaded between requests.
9-
config.cache_classes = true
9+
config.enable_reloading = false
1010

11-
# Eager load code on boot. This eager loads most of Rails and
12-
# your application in memory, allowing both threaded web servers
13-
# and those relying on copy on write to perform better.
14-
# Rake tasks automatically ignore this option for performance.
11+
# Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
1512
config.eager_load = true
1613

17-
# Full error reports are disabled and caching is turned on.
18-
config.consider_all_requests_local = false
19-
config.action_controller.perform_caching = true
14+
# Full error reports are disabled.
15+
config.consider_all_requests_local = false
2016

21-
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
22-
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
23-
# config.require_master_key = true
17+
# Cache assets for far-future expiry since they are all digest stamped.
18+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
2419

25-
# Disable serving static files from the `/public` folder by default since
26-
# Apache or NGINX already handles this.
27-
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
28-
29-
# Specifies the header that your server uses for sending files.
30-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
31-
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
20+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
21+
# config.asset_host = "http://assets.example.com"
3222

3323
# Store uploaded files on the local file system (see config/storage.yml for options).
3424
config.active_storage.service = :local
3525

36-
# Mount Action Cable outside main process or domain.
37-
# config.action_cable.mount_path = nil
38-
# config.action_cable.url = "wss://example.com/cable"
39-
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
26+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
27+
# config.assume_ssl = true
4028

4129
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
4230
# config.force_ssl = true
4331

44-
# Include generic and useful information about system operation, but avoid logging too much
45-
# information to avoid inadvertent exposure of personally identifiable information (PII).
46-
config.log_level = :info
32+
# Skip http-to-https redirect for the default health check endpoint.
33+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
4734

48-
# Prepend all log lines with the following tags.
35+
# Log to STDOUT with the current request id as a default log tag.
4936
config.log_tags = [:request_id]
37+
config.logger = ActiveSupport::TaggedLogging.logger($stdout)
5038

51-
# Use a different cache store in production.
52-
# config.cache_store = :mem_cache_store
53-
54-
# Use a real queuing backend for Active Job (and separate queues per environment).
55-
# config.active_job.queue_adapter = :resque
56-
# config.active_job.queue_name_prefix = "local_office_search_api_production"
57-
58-
config.action_mailer.perform_caching = false
39+
# Change to "debug" to log everything (including potentially personally-identifiable information!).
40+
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
5941

60-
# Ignore bad email addresses and do not raise email delivery errors.
61-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
62-
# config.action_mailer.raise_delivery_errors = false
63-
64-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65-
# the I18n.default_locale when a translation cannot be found).
66-
config.i18n.fallbacks = true
42+
# Prevent health checks from clogging up the logs.
43+
config.silence_healthcheck_path = "/up"
6744

6845
# Don't log any deprecations.
6946
config.active_support.report_deprecations = false
@@ -81,6 +58,44 @@
8158
config.logger = ActiveSupport::TaggedLogging.new(logger)
8259
end
8360

61+
# Replace the default in-process memory cache store with a durable alternative.
62+
# config.cache_store = :mem_cache_store
63+
64+
# Replace the default in-process and non-durable queuing backend for Active Job.
65+
# config.active_job.queue_adapter = :resque
66+
67+
# Ignore bad email addresses and do not raise email delivery errors.
68+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
69+
# config.action_mailer.raise_delivery_errors = false
70+
71+
# Set host to be used by links generated in mailer templates.
72+
config.action_mailer.default_url_options = { host: "example.com" }
73+
74+
# Specify outgoing SMTP server. Remember to add smtp/* credentials via bin/rails credentials:edit.
75+
# config.action_mailer.smtp_settings = {
76+
# user_name: Rails.application.credentials.dig(:smtp, :user_name),
77+
# password: Rails.application.credentials.dig(:smtp, :password),
78+
# address: "smtp.example.com",
79+
# port: 587,
80+
# authentication: :plain
81+
# }
82+
83+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
84+
# the I18n.default_locale when a translation cannot be found).
85+
config.i18n.fallbacks = true
86+
8487
# Do not dump schema after migrations.
8588
config.active_record.dump_schema_after_migration = false
89+
90+
# Only use :id for inspections in production.
91+
config.active_record.attributes_for_inspect = [:id]
92+
93+
# Enable DNS rebinding protection and other `Host` header attacks.
94+
# config.hosts = [
95+
# "example.com", # Allow requests from example.com
96+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
97+
# ]
98+
#
99+
# Skip DNS rebinding protection for the default health check endpoint.
100+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
86101
end

config/environments/test.rb

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "active_support/core_ext/integer/time"
4-
53
# The test environment is used exclusively to run your application's
64
# test suite. You never need to work with it otherwise. Remember that
75
# your test database is "scratch space" for the test suite and is wiped
@@ -10,53 +8,48 @@
108
Rails.application.configure do
119
# Settings specified here will take precedence over those in config/application.rb.
1210

13-
# Turn false under Spring and add config.action_view.cache_template_loading = true.
14-
config.cache_classes = true
11+
# While tests run files are not watched, reloading is not necessary.
12+
config.enable_reloading = false
1513

16-
# Eager loading loads your whole application. When running a single test locally,
17-
# this probably isn't necessary. It's a good idea to do in a continuous integration
18-
# system, or in some way before deploying your code.
14+
# Eager loading loads your entire application. When running a single test locally,
15+
# this is usually not necessary, and can slow down your test suite. However, it's
16+
# recommended that you enable it in continuous integration systems to ensure eager
17+
# loading is working properly before deploying your code.
1918
config.eager_load = ENV["CI"].present?
2019

21-
# Configure public file server for tests with Cache-Control for performance.
22-
config.public_file_server.enabled = true
23-
config.public_file_server.headers = {
24-
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
25-
}
20+
# Configure public file server for tests with cache-control for performance.
21+
config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
2622

27-
# Show full error reports and disable caching.
28-
config.consider_all_requests_local = true
29-
config.action_controller.perform_caching = false
23+
# Show full error reports.
24+
config.consider_all_requests_local = true
3025
config.cache_store = :null_store
3126

32-
# Raise exceptions instead of rendering exception templates.
33-
config.action_dispatch.show_exceptions = false
27+
# Render exception templates for rescuable exceptions and raise for other exceptions.
28+
config.action_dispatch.show_exceptions = :rescuable
3429

3530
# Disable request forgery protection in test environment.
3631
config.action_controller.allow_forgery_protection = false
3732

3833
# Store uploaded files on the local file system in a temporary directory.
3934
config.active_storage.service = :test
4035

41-
config.action_mailer.perform_caching = false
42-
4336
# Tell Action Mailer not to deliver emails to the real world.
4437
# The :test delivery method accumulates sent emails in the
4538
# ActionMailer::Base.deliveries array.
4639
config.action_mailer.delivery_method = :test
4740

41+
# Set host to be used by links generated in mailer templates.
42+
config.action_mailer.default_url_options = { host: "example.com" }
43+
4844
# Print deprecation notices to the stderr.
4945
config.active_support.deprecation = :stderr
5046

51-
# Raise exceptions for disallowed deprecations.
52-
config.active_support.disallowed_deprecation = :raise
53-
54-
# Tell Active Support which deprecation messages to disallow.
55-
config.active_support.disallowed_deprecation_warnings = []
56-
5747
# Raises error for missing translations.
5848
# config.i18n.raise_on_missing_translations = true
5949

6050
# Annotate rendered view with file names.
6151
# config.action_view.annotate_rendered_view_with_filenames = true
52+
53+
# Raise error when a before_action's only/except options reference missing actions.
54+
config.action_controller.raise_on_missing_callback_actions = true
6255
end

config/initializers/filter_parameter_logging.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# Be sure to restart your server when you modify this file.
44

5-
# Configure parameters to be filtered from the log file. Use this to limit dissemination of
6-
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
7-
# notations and behaviors.
5+
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
6+
# Use this to limit dissemination of sensitive information.
7+
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
88
Rails.application.config.filter_parameters += %i[
9-
passw secret token _key crypt salt certificate otp ssn
9+
passw email secret token _key crypt salt certificate otp ssn cvv cvc
1010
]

0 commit comments

Comments
 (0)