Skip to content

Commit 86e1fba

Browse files
committed
rails app:update
1 parent 6406d23 commit 86e1fba

File tree

16 files changed

+663
-367
lines changed

16 files changed

+663
-367
lines changed

bin/dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env ruby
2+
exec "./bin/rails", "server", *ARGV

bin/setup

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
require "fileutils"
33

44
APP_ROOT = File.expand_path("..", __dir__)
5-
APP_NAME = "blade-ruby-lang-org"
65

76
def system!(*args)
87
system(*args, exception: true)
@@ -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 =="
@@ -28,10 +26,9 @@ FileUtils.chdir APP_ROOT do
2826
puts "\n== Removing old logs and tempfiles =="
2927
system! "bin/rails log:clear tmp:clear"
3028

31-
puts "\n== Restarting application server =="
32-
system! "bin/rails restart"
33-
34-
# puts "\n== Configuring puma-dev =="
35-
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
36-
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
29+
unless ARGV.include?("--skip-server")
30+
puts "\n== Starting development server =="
31+
STDOUT.flush # flush the output before exec(2) so that it displays
32+
exec "bin/dev"
33+
end
3734
end

config/environments/development.rb

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
Rails.application.configure do
44
# Settings specified here will take precedence over those in config/application.rb.
55

6-
# In the development environment your application's code is reloaded any time
7-
# it changes. This slows down response time but is perfect for development
8-
# since you don't have to restart the web server when you make code changes.
6+
# Make code changes take effect immediately without server restart.
97
config.enable_reloading = true
108

119
# Do not eager load code on boot.
@@ -17,53 +15,46 @@
1715
# Enable server timing.
1816
config.server_timing = true
1917

20-
# Enable/disable caching. By default caching is disabled.
21-
# Run rails dev:cache to toggle caching.
18+
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
19+
# Run rails dev:cache to toggle Action Controller caching.
2220
if Rails.root.join("tmp/caching-dev.txt").exist?
2321
config.action_controller.perform_caching = true
2422
config.action_controller.enable_fragment_cache_logging = true
25-
26-
config.cache_store = :memory_store
27-
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
23+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
2824
else
2925
config.action_controller.perform_caching = false
30-
31-
config.cache_store = :null_store
3226
end
3327

28+
# Change to :null_store to avoid any caching.
29+
config.cache_store = :memory_store
30+
3431
# Store uploaded files on the local file system (see config/storage.yml for options).
3532
config.active_storage.service = :local
3633

3734
# Don't care if the mailer can't send.
3835
config.action_mailer.raise_delivery_errors = false
3936

40-
# Disable caching for Action Mailer templates even if Action Controller
41-
# caching is enabled.
37+
# Make template changes take effect immediately.
4238
config.action_mailer.perform_caching = false
4339

40+
# Set localhost to be used by links generated in mailer templates.
4441
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
4542

4643
# Print deprecation notices to the Rails logger.
4744
config.active_support.deprecation = :log
4845

49-
# Raise exceptions for disallowed deprecations.
50-
config.active_support.disallowed_deprecation = :raise
51-
52-
# Tell Active Support which deprecation messages to disallow.
53-
config.active_support.disallowed_deprecation_warnings = []
54-
5546
# Raise an error on page load if there are pending migrations.
5647
config.active_record.migration_error = :page_load
5748

5849
# Highlight code that triggered database queries in logs.
5950
config.active_record.verbose_query_logs = true
6051

52+
# Append comments with runtime information tags to SQL queries in logs.
53+
config.active_record.query_log_tags_enabled = true
54+
6155
# Highlight code that enqueued background job in logs.
6256
config.active_job.verbose_enqueue_logs = true
6357

64-
# Suppress logger output for asset requests.
65-
config.assets.quiet = true
66-
6758
# Raises error for missing translations.
6859
# config.i18n.raise_on_missing_translations = true
6960

config/environments/production.rb

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,89 +6,72 @@
66
# Code is not reloaded between requests.
77
config.enable_reloading = false
88

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

15-
# Full error reports are disabled and caching is turned on.
12+
# Full error reports are disabled.
1613
config.consider_all_requests_local = false
17-
config.action_controller.perform_caching = true
18-
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).
21-
# config.require_master_key = true
22-
23-
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
24-
# config.public_file_server.enabled = false
2514

26-
# Compress CSS using a preprocessor.
27-
# config.assets.css_compressor = :sass
15+
# Turn on fragment caching in view templates.
16+
config.action_controller.perform_caching = true
2817

29-
# Do not fall back to assets pipeline if a precompiled asset is missed.
30-
config.assets.compile = false
18+
# Cache assets for far-future expiry since they are all digest stamped.
19+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
3120

3221
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
3322
# config.asset_host = "http://assets.example.com"
3423

35-
# Specifies the header that your server uses for sending files.
36-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
37-
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
38-
3924
# Store uploaded files on the local file system (see config/storage.yml for options).
4025
config.active_storage.service = :local
4126

42-
# Mount Action Cable outside main process or domain.
43-
# config.action_cable.mount_path = nil
44-
# config.action_cable.url = "wss://example.com/cable"
45-
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
46-
4727
# 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
28+
config.assume_ssl = true
5029

5130
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
5231
config.force_ssl = true
5332

5433
# Skip http-to-https redirect for the default health check endpoint.
5534
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
5635

57-
# Log to STDOUT by default
58-
config.logger = ActiveSupport::Logger.new(STDOUT)
59-
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
60-
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
61-
62-
# Prepend all log lines with the following tags.
36+
# Log to STDOUT with the current request id as a default log tag.
6337
config.log_tags = [ :request_id ]
38+
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
6439

65-
# "info" includes generic and useful information about system operation, but avoids logging too much
66-
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
67-
# want to log everything, set the level to "debug".
40+
# Change to "debug" to log everything (including potentially personally-identifiable information!)
6841
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
6942

70-
# Use a different cache store in production.
43+
# Prevent health checks from clogging up the logs.
44+
config.silence_healthcheck_path = "/up"
45+
46+
# Don't log any deprecations.
47+
config.active_support.report_deprecations = false
48+
49+
# Replace the default in-process memory cache store with a durable alternative.
7150
# config.cache_store = :mem_cache_store
7251

73-
# Use a real queuing backend for Active Job (and separate queues per environment).
52+
# Replace the default in-process and non-durable queuing backend for Active Job.
7453
# config.active_job.queue_adapter = :resque
75-
# config.active_job.queue_name_prefix = "blade_ruby_lang_org_production"
76-
77-
# Disable caching for Action Mailer templates even if Action Controller
78-
# caching is enabled.
79-
config.action_mailer.perform_caching = false
8054

8155
# Ignore bad email addresses and do not raise email delivery errors.
8256
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
8357
# config.action_mailer.raise_delivery_errors = false
8458

59+
# Set host to be used by links generated in mailer templates.
60+
config.action_mailer.default_url_options = { host: "example.com" }
61+
62+
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
63+
# config.action_mailer.smtp_settings = {
64+
# user_name: Rails.application.credentials.dig(:smtp, :user_name),
65+
# password: Rails.application.credentials.dig(:smtp, :password),
66+
# address: "smtp.example.com",
67+
# port: 587,
68+
# authentication: :plain
69+
# }
70+
8571
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
8672
# the I18n.default_locale when a translation cannot be found).
8773
config.i18n.fallbacks = true
8874

89-
# Don't log any deprecations.
90-
config.active_support.report_deprecations = false
91-
9275
# Do not dump schema after migrations.
9376
config.active_record.dump_schema_after_migration = false
9477

@@ -100,6 +83,7 @@
10083
# "example.com", # Allow requests from example.com
10184
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
10285
# ]
86+
#
10387
# Skip DNS rebinding protection for the default health check endpoint.
10488
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
10589
end

config/environments/test.rb

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require "active_support/core_ext/integer/time"
2-
31
# The test environment is used exclusively to run your application's
42
# test suite. You never need to work with it otherwise. Remember that
53
# your test database is "scratch space" for the test suite and is wiped
@@ -17,12 +15,11 @@
1715
# loading is working properly before deploying your code.
1816
config.eager_load = ENV["CI"].present?
1917

20-
# Configure public file server for tests with Cache-Control for performance.
21-
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
18+
# Configure public file server for tests with cache-control for performance.
19+
config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
2220

23-
# Show full error reports and disable caching.
21+
# Show full error reports.
2422
config.consider_all_requests_local = true
25-
config.action_controller.perform_caching = false
2623
config.cache_store = :null_store
2724

2825
# Render exception templates for rescuable exceptions and raise for other exceptions.
@@ -34,28 +31,17 @@
3431
# Store uploaded files on the local file system in a temporary directory.
3532
config.active_storage.service = :test
3633

37-
# Disable caching for Action Mailer templates even if Action Controller
38-
# caching is enabled.
39-
config.action_mailer.perform_caching = false
40-
4134
# Tell Action Mailer not to deliver emails to the real world.
4235
# The :test delivery method accumulates sent emails in the
4336
# ActionMailer::Base.deliveries array.
4437
config.action_mailer.delivery_method = :test
4538

46-
# Unlike controllers, the mailer instance doesn't have any context about the
47-
# incoming request so you'll need to provide the :host parameter yourself.
48-
config.action_mailer.default_url_options = { host: "www.example.com" }
39+
# Set host to be used by links generated in mailer templates.
40+
config.action_mailer.default_url_options = { host: "example.com" }
4941

5042
# Print deprecation notices to the stderr.
5143
config.active_support.deprecation = :stderr
5244

53-
# Raise exceptions for disallowed deprecations.
54-
config.active_support.disallowed_deprecation = :raise
55-
56-
# Tell Active Support which deprecation messages to disallow.
57-
config.active_support.disallowed_deprecation_warnings = []
58-
5945
# Raises error for missing translations.
6046
# config.i18n.raise_on_missing_translations = true
6147

config/initializers/assets.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@
55

66
# Add additional assets to the asset load path.
77
# Rails.application.config.assets.paths << Emoji.images_path
8-
9-
# Precompile additional assets.
10-
# application.js, application.css, and all non-JS/CSS in the app/assets
11-
# folder are already added.
12-
# Rails.application.config.assets.precompile += %w[ admin.js admin.css ]

config/initializers/filter_parameter_logging.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# Use this to limit dissemination of sensitive information.
55
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
66
Rails.application.config.filter_parameters += [
7-
:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
7+
:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc
88
]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Be sure to restart your server when you modify this file.
2+
#
3+
# This file eases your Rails 8.0 framework defaults upgrade.
4+
#
5+
# Uncomment each configuration one by one to switch to the new default.
6+
# Once your application is ready to run with all new defaults, you can remove
7+
# this file and set the `config.load_defaults` to `8.0`.
8+
#
9+
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
10+
# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
11+
12+
###
13+
# Specifies whether `to_time` methods preserve the UTC offset of their receivers or preserves the timezone.
14+
# If set to `:zone`, `to_time` methods will use the timezone of their receivers.
15+
# If set to `:offset`, `to_time` methods will use the UTC offset.
16+
# If `false`, `to_time` methods will convert to the local system UTC offset instead.
17+
#++
18+
# Rails.application.config.active_support.to_time_preserves_timezone = :zone
19+
20+
###
21+
# When both `If-Modified-Since` and `If-None-Match` are provided by the client
22+
# only consider `If-None-Match` as specified by RFC 7232 Section 6.
23+
# If set to `false` both conditions need to be satisfied.
24+
#++
25+
# Rails.application.config.action_dispatch.strict_freshness = true
26+
27+
###
28+
# Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks.
29+
#++
30+
# Regexp.timeout = 1

config/puma.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# This configuration file will be evaluated by Puma. The top-level methods that
22
# are invoked here are part of Puma's configuration DSL. For more information
33
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
4-
4+
#
55
# Puma starts a configurable number of processes (workers) and each process
66
# serves each request in a thread from an internal thread pool.
77
#
8+
# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
9+
# should only set this value when you want to run 2 or more workers. The
10+
# default is already 1.
11+
#
812
# The ideal number of threads per worker depends both on how much time the
913
# application spends waiting for IO operations and on how much you wish to
10-
# to prioritize throughput over latency.
14+
# prioritize throughput over latency.
1115
#
1216
# As a rule of thumb, increasing the number of threads will increase how much
1317
# traffic a given process can handle (throughput), but due to CRuby's
@@ -29,6 +33,9 @@
2933
# Allow puma to be restarted by `bin/rails restart` command.
3034
plugin :tmp_restart
3135

36+
# Run the Solid Queue supervisor inside of Puma for single-server deployments
37+
plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
38+
3239
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
3340
# In other environments, only set the PID file if requested.
3441
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]

0 commit comments

Comments
 (0)