Skip to content

Commit 6d3cece

Browse files
committed
Rails app:update: Config updates
These files had some changes we accepted and some we kept our own configuration. Note: Updated config to force SSL in prod. This should have been set before and had an open ticket to resolve so I just made the change while touching these files. https://mitlibraries.atlassian.net/browse/GDT-207
1 parent 02d4a79 commit 6d3cece

File tree

4 files changed

+61
-34
lines changed

4 files changed

+61
-34
lines changed

config/application.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,18 @@ class Application < Rails::Application
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

0 commit comments

Comments
 (0)