Skip to content

Commit 5c22a52

Browse files
authored
Merge pull request #125 from MITLibraries/rails71
Rails71 app:update
2 parents 39f1242 + eb891a4 commit 5c22a52

14 files changed

+154
-69
lines changed

bin/rails

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
2-
APP_PATH = File.expand_path('../config/application', __dir__)
3-
require_relative '../config/boot'
4-
require 'rails/commands'
2+
APP_PATH = File.expand_path("../config/application", __dir__)
3+
require_relative "../config/boot"
4+
require "rails/commands"

bin/rake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env ruby
2-
require_relative '../config/boot'
3-
require 'rake'
2+
require_relative "../config/boot"
3+
require "rake"
44
Rake.application.run

bin/setup

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
#!/usr/bin/env ruby
2-
require 'fileutils'
2+
require "fileutils"
33

44
# path to your application root.
5-
APP_ROOT = File.expand_path('..', __dir__)
5+
APP_ROOT = File.expand_path("..", __dir__)
66

77
def system!(*args)
8-
system(*args) || abort("\n== Command #{args} failed ==")
8+
system(*args, exception: true)
99
end
1010

1111
FileUtils.chdir APP_ROOT do
1212
# This script is a way to set up or update your development environment automatically.
1313
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
1414
# Add necessary setup steps to this file.
1515

16-
puts '== Installing dependencies =='
17-
system! 'gem install bundler --conservative'
18-
system('bundle check') || system!('bundle install')
16+
puts "== Installing dependencies =="
17+
system! "gem install bundler --conservative"
18+
system("bundle check") || system!("bundle install")
1919

2020
# puts "\n== Copying sample files =="
2121
# unless File.exist?("config/database.yml")
2222
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
2323
# end
2424

2525
puts "\n== Preparing database =="
26-
system! 'bin/rails db:prepare'
26+
system! "bin/rails db:prepare"
2727

2828
puts "\n== Removing old logs and tempfiles =="
29-
system! 'bin/rails log:clear tmp:clear'
29+
system! "bin/rails log:clear tmp:clear"
3030

3131
puts "\n== Restarting application server =="
32-
system! 'bin/rails restart'
32+
system! "bin/rails restart"
3333
end

config/application.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,23 @@ class Application < Rails::Application
1818
config.flipflop.raise_strategy_errors = nil
1919

2020
# Initialize configuration defaults for originally generated Rails version.
21-
config.load_defaults 7.0
21+
config.load_defaults 7.1
2222

2323
# Enable asset pipeline
2424
config.assets.enabled = true
2525
config.assets.version = '1.0'
26+
27+
# Please, add to the `ignore` list any other `lib` subdirectories that do
28+
# not contain `.rb` files, or that should not be reloaded or eager loaded.
29+
# Common ones are `templates`, `generators`, or `middleware`, for example.
30+
config.autoload_lib(ignore: %w(assets tasks))
31+
32+
# Configuration for the application, engines, and railties goes here.
33+
#
34+
# These settings can be overridden in specific environments using the files
35+
# in config/environments, which are processed later.
36+
#
37+
# config.time_zone = "Central Time (US & Canada)"
38+
# config.eager_load_paths << Rails.root.join("extras")
2639
end
2740
end

config/environments/development.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# In the development environment your application's code is reloaded any time
1515
# it changes. This slows down response time but is perfect for development
1616
# since you don't have to restart the web server when you make code changes.
17-
config.cache_classes = false
17+
config.enable_reloading = true
1818

1919
# Do not eager load code on boot.
2020
config.eager_load = false
@@ -64,6 +64,9 @@
6464
# Highlight code that triggered database queries in logs.
6565
config.active_record.verbose_query_logs = true
6666

67+
# Highlight code that enqueued background job in logs.
68+
config.active_job.verbose_enqueue_logs = true
69+
6770
# Suppress logger output for asset requests.
6871
config.assets.quiet = true
6972

@@ -75,4 +78,7 @@
7578

7679
# Uncomment if you wish to allow Action Cable access from any origin.
7780
# config.action_cable.disable_request_forgery_protection = true
81+
82+
# Raise error when a before_action's only/except options reference missing actions
83+
config.action_controller.raise_on_missing_callback_actions = true
7884
end

config/environments/production.rb

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Settings specified here will take precedence over those in config/application.rb.
55

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

99
# Eager load code on boot. This eager loads most of Rails and
1010
# your application in memory, allowing both threaded web servers
@@ -13,21 +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

19-
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20-
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
19+
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
20+
# 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-
# Disable serving static files from the `/public` folder by default since
24-
# Apache or NGINX already handles this.
23+
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
2524
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
2625

2726
# Compress CSS using a preprocessor.
2827
# config.assets.css_compressor = :sass
2928

30-
# 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.
3130
config.assets.compile = false
3231

3332
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
@@ -45,21 +44,31 @@
4544
# config.action_cable.url = "wss://example.com/cable"
4645
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
4746

47+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
48+
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
49+
# config.assume_ssl = true
50+
4851
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
49-
# config.force_ssl = true
52+
config.force_ssl = true
5053

51-
# Include generic and useful information about system operation, but avoid logging too much
52-
# information to avoid inadvertent exposure of personally identifiable information (PII).
53-
config.log_level = :info
54+
# Log to STDOUT by default
55+
config.logger = ActiveSupport::Logger.new(STDOUT)
56+
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
57+
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
5458

5559
# Prepend all log lines with the following tags.
5660
config.log_tags = [ :request_id ]
5761

62+
# "info" includes generic and useful information about system operation, but avoids logging too much
63+
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
64+
# want to log everything, set the level to "debug".
65+
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
66+
5867
# Use a different cache store in production.
5968
# config.cache_store = :mem_cache_store
6069

6170
# Use a real queuing backend for Active Job (and separate queues per environment).
62-
# config.active_job.queue_adapter = :resque
71+
# config.active_job.queue_adapter = :resque
6372
# config.active_job.queue_name_prefix = "timdex_ui_production"
6473

6574
config.action_mailer.perform_caching = false
@@ -75,19 +84,14 @@
7584
# Don't log any deprecations.
7685
config.active_support.report_deprecations = false
7786

78-
# Use default logging formatter so that PID and timestamp are not suppressed.
79-
config.log_formatter = ::Logger::Formatter.new
80-
81-
# Use a different logger for distributed setups.
82-
# require "syslog/logger"
83-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
84-
85-
if ENV["RAILS_LOG_TO_STDOUT"].present?
86-
logger = ActiveSupport::Logger.new(STDOUT)
87-
logger.formatter = config.log_formatter
88-
config.logger = ActiveSupport::TaggedLogging.new(logger)
89-
end
90-
9187
# Do not dump schema after migrations.
9288
config.active_record.dump_schema_after_migration = false
89+
90+
# Enable DNS rebinding protection and other `Host` header attacks.
91+
# config.hosts = [
92+
# "example.com", # Allow requests from example.com
93+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
94+
# ]
95+
# Skip DNS rebinding protection for the default health check endpoint.
96+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
9397
end

config/environments/test.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616

1717
# Settings specified here will take precedence over those in config/application.rb.
1818

19-
# Turn false under Spring and add config.action_view.cache_template_loading = true.
20-
config.cache_classes = true
19+
# While tests run files are not watched, reloading is not necessary.
20+
config.enable_reloading = false
2121

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

2728
# Configure public file server for tests with Cache-Control for performance.
@@ -31,12 +32,12 @@
3132
}
3233

3334
# Show full error reports and disable caching.
34-
config.consider_all_requests_local = true
35+
config.consider_all_requests_local = true
3536
config.action_controller.perform_caching = false
3637
config.cache_store = :null_store
3738

38-
# Raise exceptions instead of rendering exception templates.
39-
config.action_dispatch.show_exceptions = false
39+
# Render exception templates for rescuable exceptions and raise for other exceptions.
40+
config.action_dispatch.show_exceptions = :rescuable
4041

4142
# Disable request forgery protection in test environment.
4243
config.action_controller.allow_forgery_protection = false
@@ -68,4 +69,7 @@
6869

6970
# Annotate rendered view with file names.
7071
# config.action_view.annotate_rendered_view_with_filenames = true
72+
73+
# Raise error when a before_action's only/except options reference missing actions
74+
config.action_controller.raise_on_missing_callback_actions = true
7175
end
Lines changed: 6 additions & 7 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-
# Define an application-wide content security policy
4-
# For further information see the following documentation
5-
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
3+
# Define an application-wide content security policy.
4+
# See the Securing Rails Applications Guide for more information:
5+
# https://guides.rubyonrails.org/security.html#content-security-policy-header
66

77
# Rails.application.configure do
88
# config.content_security_policy do |policy|
@@ -16,11 +16,10 @@
1616
# # policy.report_uri "/csp-violation-report-endpoint"
1717
# end
1818
#
19-
# # Generate session nonces for permitted importmap and inline scripts
19+
# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
2020
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21-
# config.content_security_policy_nonce_directives = %w(script-src)
21+
# config.content_security_policy_nonce_directives = %w(script-src style-src)
2222
#
23-
# # Report CSP violations to a specified URI. See:
24-
# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
23+
# # Report violations without enforcing the policy.
2524
# # config.content_security_policy_report_only = true
2625
# 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 filtered from the log file. Use this to limit dissemination of
4-
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5-
# notations and behaviors.
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.
5+
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
66
Rails.application.config.filter_parameters += [
77
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
88
]
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
# Be sure to restart your server when you modify this file.
2+
13
# Define an application-wide HTTP permissions policy. For further
2-
# information see https://developers.google.com/web/updates/2018/06/feature-policy
3-
#
4-
# Rails.application.config.permissions_policy do |f|
5-
# f.camera :none
6-
# f.gyroscope :none
7-
# f.microphone :none
8-
# f.usb :none
9-
# f.fullscreen :self
10-
# f.payment :self, "https://secure.example.com"
4+
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
5+
6+
# Rails.application.config.permissions_policy do |policy|
7+
# policy.camera :none
8+
# policy.gyroscope :none
9+
# policy.microphone :none
10+
# policy.usb :none
11+
# policy.fullscreen :self
12+
# policy.payment :self, "https://secure.example.com"
1113
# end

0 commit comments

Comments
 (0)