Skip to content

Commit db08292

Browse files
committed
rails app:update
1 parent 8ba0764 commit db08292

18 files changed

+691
-313
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/rubocop

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
require "rubygems"
3+
require "bundler/setup"
4+
5+
# explicit rubocop config increases performance slightly while avoiding config confusion.
6+
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
7+
8+
load Gem.bin_path("rubocop", "rubocop")

bin/setup

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
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)
@@ -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,6 +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"
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
3334
end

config/application.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ class Application < Rails::Application
2626
# Please, add to the `ignore` list any other `lib` subdirectories that do
2727
# not contain `.rb` files, or that should not be reloaded or eager loaded.
2828
# Common ones are `templates`, `generators`, or `middleware`, for example.
29-
config.autoload_lib(ignore: %w(assets tasks))
29+
config.autoload_lib(ignore: %w[assets tasks])
3030

3131
# Configuration for the application, engines, and railties goes here.
3232
#
3333
# These settings can be overridden in specific environments using the files
3434
# in config/environments, which are processed later.
3535
#
3636
config.time_zone = "Asia/Tokyo"
37-
3837
# config.eager_load_paths << Rails.root.join("extras")
3938

4039
# Don't generate system test files.

config/environments/development.rb

Lines changed: 15 additions & 23 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.
@@ -14,49 +12,43 @@
1412
# Show full error reports.
1513
config.consider_all_requests_local = true
1614

17-
# Enable server timing
15+
# 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 = {
28-
"Cache-Control" => "public, max-age=#{2.days.to_i}"
29-
}
23+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
3024
else
3125
config.action_controller.perform_caching = false
32-
33-
config.cache_store = :null_store
3426
end
3527

28+
# Change to :null_store to avoid any caching.
29+
config.cache_store = :memory_store
30+
3631
# Print deprecation notices to the Rails logger.
3732
config.active_support.deprecation = :log
3833

39-
# Raise exceptions for disallowed deprecations.
40-
config.active_support.disallowed_deprecation = :raise
41-
42-
# Tell Active Support which deprecation messages to disallow.
43-
config.active_support.disallowed_deprecation_warnings = []
44-
4534
# Raise an error on page load if there are pending migrations.
4635
config.active_record.migration_error = :page_load
4736

4837
# Highlight code that triggered database queries in logs.
4938
config.active_record.verbose_query_logs = true
5039

51-
# Suppress logger output for asset requests.
52-
config.assets.quiet = true
40+
# Append comments with runtime information tags to SQL queries in logs.
41+
config.active_record.query_log_tags_enabled = true
5342

5443
# Raises error for missing translations.
5544
# config.i18n.raise_on_missing_translations = true
5645

5746
# Annotate rendered view with file names.
58-
# config.action_view.annotate_rendered_view_with_filenames = true
47+
config.action_view.annotate_rendered_view_with_filenames = true
5948

60-
# Raise error when a before_action's only/except options reference missing actions
49+
# Raise error when a before_action's only/except options reference missing actions.
6150
config.action_controller.raise_on_missing_callback_actions = true
51+
52+
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
53+
# config.generators.apply_rubocop_autocorrect_after_generate!
6254
end

config/environments/production.rb

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,62 @@
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
2214

23-
# Disable serving static files from the `/public` folder by default since
24-
# Apache or NGINX already handles this.
25-
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
26-
27-
# Compress CSS using a preprocessor.
28-
# config.assets.css_compressor = :sass
15+
# Turn on fragment caching in view templates.
16+
config.action_controller.perform_caching = true
2917

30-
# Do not fallback to assets pipeline if a precompiled asset is missed.
31-
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}" }
3220

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

36-
# Specifies the header that your server uses for sending files.
37-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
38-
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
39-
4024
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
41-
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
4225
config.assume_ssl = true
4326

4427
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
4528
config.force_ssl = true
46-
config.ssl_options = {
47-
hsts: false, # = Strict-Transport-Security: max-age: 0
48-
}
4929

50-
# Log to STDOUT by default
51-
config.logger = ActiveSupport::Logger.new(STDOUT)
52-
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
53-
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
30+
# Skip http-to-https redirect for the default health check endpoint.
31+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
5432

55-
# Prepend all log lines with the following tags.
33+
# Log to STDOUT with the current request id as a default log tag.
5634
config.log_tags = [ :request_id ]
35+
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
5736

58-
# Info include generic and useful information about system operation, but avoids logging too much
59-
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
60-
# want to log everything, set the level to "debug".
37+
# Change to "debug" to log everything (including potentially personally-identifiable information!)
6138
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
6239

63-
# Use a different cache store in production.
40+
# Prevent health checks from clogging up the logs.
41+
config.silence_healthcheck_path = "/up"
42+
43+
# Don't log any deprecations.
44+
config.active_support.report_deprecations = false
45+
46+
# Replace the default in-process memory cache store with a durable alternative.
6447
# config.cache_store = :mem_cache_store
6548

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

70-
# Don't log any deprecations.
71-
config.active_support.report_deprecations = false
72-
7353
# Do not dump schema after migrations.
7454
config.active_record.dump_schema_after_migration = false
7555

56+
# Only use :id for inspections in production.
57+
config.active_record.attributes_for_inspect = [ :id ]
58+
7659
# Enable DNS rebinding protection and other `Host` header attacks.
7760
# config.hosts = [
7861
# "example.com", # Allow requests from example.com
7962
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
8063
# ]
64+
#
8165
# Skip DNS rebinding protection for the default health check endpoint.
8266
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
8367
end

config/environments/test.rb

Lines changed: 4 additions & 16 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,15 +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.enabled = true
22-
config.public_file_server.headers = {
23-
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
24-
}
18+
# Configure public file server for tests with cache-control for performance.
19+
config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
2520

26-
# Show full error reports and disable caching.
21+
# Show full error reports.
2722
config.consider_all_requests_local = true
28-
config.action_controller.perform_caching = false
2923
config.cache_store = :null_store
3024

3125
# Render exception templates for rescuable exceptions and raise for other exceptions.
@@ -37,18 +31,12 @@
3731
# Print deprecation notices to the stderr.
3832
config.active_support.deprecation = :stderr
3933

40-
# Raise exceptions for disallowed deprecations.
41-
config.active_support.disallowed_deprecation = :raise
42-
43-
# Tell Active Support which deprecation messages to disallow.
44-
config.active_support.disallowed_deprecation_warnings = []
45-
4634
# Raises error for missing translations.
4735
# config.i18n.raise_on_missing_translations = true
4836

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

52-
# Raise error when a before_action's only/except options reference missing actions
40+
# Raise error when a before_action's only/except options reference missing actions.
5341
config.action_controller.raise_on_missing_callback_actions = true
5442
end

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, :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

0 commit comments

Comments
 (0)