Skip to content

Commit

Permalink
Rails7.1: update configs via rails app:update
Browse files Browse the repository at this point in the history
  • Loading branch information
mockdeep committed Oct 8, 2023
1 parent 296658d commit df2de65
Show file tree
Hide file tree
Showing 9 changed files with 342 additions and 56 deletions.
2 changes: 1 addition & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require "fileutils"
APP_ROOT = File.expand_path("..", __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
system(*args, exception: true)
end

FileUtils.chdir(APP_ROOT) do
Expand Down
5 changes: 5 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class Stringer::Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults(7.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.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: ["assets", "tasks"])

# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
Expand Down
10 changes: 7 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# 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.
config.cache_classes = false
config.enable_reloading = true

# Do not eager load code on boot.
config.eager_load = false
Expand Down Expand Up @@ -51,6 +51,9 @@
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true

# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true

# Suppress logger output for asset requests.
config.assets.quiet = true

Expand All @@ -60,6 +63,7 @@
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
# Raise error when a before_action's only/except options reference missing
# actions
config.action_controller.raise_on_missing_callback_actions = true
end
66 changes: 39 additions & 27 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# config/application.rb.

# Code is not reloaded between requests.
config.cache_classes = true
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
Expand All @@ -19,14 +19,15 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Ensures that a master key has been made available in either
# ENV["RAILS_MASTER_KEY"] or in config/master.key. This key is used to
# decrypt credentials (and other encrypted files). config.require_master_key
# = 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

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Enable static file serving from the `/public` folder (turn off if using
# NGINX/Apache for it).
config.public_file_server.enabled = true

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
Expand All @@ -41,44 +42,55 @@
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX

# 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.
# config.force_ssl = true
config.force_ssl = true

# Include generic and useful information about system operation, but avoid
# logging too much information to avoid inadvertent exposure of personally
# identifiable information (PII).
config.log_level = :info
# Log to STDOUT by default
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = Logger::Formatter.new
config.logger = ActiveSupport::TaggedLogging.new(logger)

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

# Info include 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".
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")

# Use a different cache store in production.
# config.cache_store = :mem_cache_store

# Use a real queuing backend for Active Job (and separate queues per
# environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "stringer_production"

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true

# Don't log any deprecations.
config.active_support.report_deprecations = false

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = Logger::Formatter.new

# Use a different logger for distributed setups.
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new
# "app-name")

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

# Enable DNS rebinding protection and other `Host` header attacks.
# config.hosts = [
# "example.com", # Allow requests from example.com
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
# ]
# Skip DNS rebinding protection for the default health check endpoint.
# config.host_authorization =
# { exclude: ->(request) { request.path == "/up" } }

config.good_job.execution_mode = :async
end
21 changes: 13 additions & 8 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
# Settings specified here will take precedence over those in
# config/application.rb.

# Turn false under Spring and add config.action_view.cache_template_loading =
# true.
config.cache_classes = true

# Eager loading loads your whole application. When running a single test
# locally, this probably isn't necessary. It's a good idea to do in a
# continuous integration system, or in some way before deploying your code.
# While tests run files are not watched, reloading is not necessary.
config.enable_reloading = false

# Eager loading loads your entire application. When running a single test
# locally, this is usually not necessary, and can slow down your test suite.
# However, it's recommended that you enable it in continuous integration
# systems to ensure eager loading is working properly before deploying your
# code.
config.eager_load = ENV["CI"].present?

# Configure public file server for tests with Cache-Control for performance.
Expand All @@ -32,7 +33,7 @@
config.cache_store = :null_store

# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
config.action_dispatch.show_exceptions = :rescuable

# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
Expand All @@ -51,4 +52,8 @@

# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

# Raise error when a before_action's only/except options reference missing
# actions
config.action_controller.raise_on_missing_callback_actions = true
end
9 changes: 5 additions & 4 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
# # policy.report_uri "/csp-violation-report-endpoint"
# end
#
# # Generate session nonces for permitted importmap and inline scripts
# config.content_security_policy_nonce_generator = ->(request) {
# request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src)
# # Generate session nonces for permitted importmap, inline scripts, and
# inline styles.
# config.content_security_policy_nonce_generator =
# ->(request) { request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src style-src)
#
# # Report violations without enforcing the policy.
# # config.content_security_policy_report_only = true
Expand Down
8 changes: 4 additions & 4 deletions config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

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

# Configure parameters to be filtered from the log file. Use this to limit
# dissemination of sensitive information. See the
# ActiveSupport::ParameterFilter documentation for supported notations and
# behaviors.
# Configure parameters to be partially matched (e.g. passw matches password)
# and filtered from the log file. Use this to limit dissemination of sensitive
# information. See the ActiveSupport::ParameterFilter documentation for
# supported notations and behaviors.
Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
]
Loading

0 comments on commit df2de65

Please sign in to comment.