Skip to content

Commit 7fe9d49

Browse files
committed
Rails 8.0: rails app:update
1 parent ef80a9b commit 7fe9d49

File tree

20 files changed

+673
-372
lines changed

20 files changed

+673
-372
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/rails

Lines changed: 1 addition & 1 deletion
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__)
2+
APP_PATH = File.expand_path("../config/application", __dir__)
33
require_relative "../config/boot"
44
require "rails/commands"

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 = "planner"
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/application.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ class Application < Rails::Application
1212
# Initialize configuration defaults for originally generated Rails version.
1313
config.load_defaults 7.2
1414

15-
config.autoload_lib(ignore: %w(assets tasks))
15+
# Please, add to the `ignore` list any other `lib` subdirectories that do
16+
# not contain `.rb` files, or that should not be reloaded or eager loaded.
17+
# Common ones are `templates`, `generators`, or `middleware`, for example.
18+
config.autoload_lib(ignore: %w[assets tasks])
1619

1720
# Configuration for the application, engines, and railties goes here.
1821
#

config/boot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
1+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
22

33
require "bundler/setup" # Set up gems listed in the Gemfile.

config/environments/development.rb

Lines changed: 12 additions & 15 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,47 +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-
2623
config.cache_store = :memory_store
27-
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
24+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
2825
else
2926
config.action_controller.perform_caching = false
3027

3128
config.cache_store = :null_store
3229
end
3330

31+
# Change to :null_store to avoid any caching.
32+
# config.cache_store = :memory_store
33+
3434
# Store uploaded files on the local file system (see config/storage.yml for options).
3535
config.active_storage.service = :local
3636

3737
# Don't care if the mailer can't send.
3838
config.action_mailer.raise_delivery_errors = false
3939

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

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

4646
# Print deprecation notices to the Rails logger.
4747
config.active_support.deprecation = :log
4848

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-
5549
# Raise an error on page load if there are pending migrations.
5650
config.active_record.migration_error = :page_load
5751

5852
# Highlight code that triggered database queries in logs.
5953
config.active_record.verbose_query_logs = true
6054

55+
# Append comments with runtime information tags to SQL queries in logs.
56+
config.active_record.query_log_tags_enabled = true
57+
6158
# Highlight code that enqueued background job in logs.
6259
config.active_job.verbose_enqueue_logs = true
6360

config/environments/production.rb

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,30 @@
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 `public/`, relying on NGINX/Apache to do so instead.
24-
# config.public_file_server.enabled = false
15+
# Turn on fragment caching in view templates.
16+
config.action_controller.perform_caching = true
2517

26-
# Compress CSS using a preprocessor.
27-
# config.assets.css_compressor = :sass
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}" }
2820

29-
# Compress JS using a preprocessor.
3021
config.assets.js_compressor = :terser
3122

3223
# Do not fall back to assets pipeline if a precompiled asset is missed.
3324
config.assets.compile = false
3425

3526
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
36-
# config.asset_host = 'http://assets.example.com'
37-
38-
# Specifies the header that your server uses for sending files.
39-
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
40-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
27+
# config.asset_host = "http://assets.example.com"
4128

4229
# Store uploaded files on the local file system (see config/storage.yml for options).
4330
config.active_storage.service = :local
4431

45-
# Mount Action Cable outside main process or domain.
46-
# config.action_cable.mount_path = nil
47-
# config.action_cable.url = "wss://example.com/cable"
48-
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
49-
5032
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
51-
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
5233
# config.assume_ssl = true
5334

5435
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
@@ -57,25 +38,24 @@
5738
# Skip http-to-https redirect for the default health check endpoint.
5839
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
5940

60-
# Log to STDOUT by default
61-
config.logger = ActiveSupport::Logger.new(STDOUT)
62-
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
63-
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
64-
65-
# Prepend all log lines with the following tags.
41+
# Log to STDOUT with the current request id as a default log tag.
6642
config.log_tags = [ :request_id ]
43+
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
6744

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

73-
# Use a different cache store in production.
48+
# Prevent health checks from clogging up the logs.
49+
config.silence_healthcheck_path = "/up"
50+
51+
# Don't log any deprecations.
52+
config.active_support.report_deprecations = false
53+
54+
# Replace the default in-process memory cache store with a durable alternative.
7455
# config.cache_store = :mem_cache_store
7556

76-
# Use a real queuing backend for Active Job (and separate queues per environment).
57+
# Replace the default in-process and non-durable queuing backend for Active Job.
7758
# config.active_job.queue_adapter = :resque
78-
# config.active_job.queue_name_prefix = "planner_production"
7959

8060
# Disable caching for Action Mailer templates even if Action Controller
8161
# caching is enabled.
@@ -85,13 +65,25 @@
8565
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
8666
# config.action_mailer.raise_delivery_errors = false
8767

68+
# Set host to be used by links generated in mailer templates.
69+
config.action_mailer.default_url_options = { host: 'codebar.io' }
70+
71+
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
72+
config.action_mailer.smtp_settings = {
73+
port: '587',
74+
address: 'smtp.sendgrid.net',
75+
user_name: ENV['SENDGRID_USERNAME'],
76+
password: ENV['SENDGRID_PASSWORD'],
77+
domain: 'heroku.com',
78+
authentication: :plain,
79+
enable_starttls_auto: true
80+
}
81+
ActionMailer::Base.delivery_method = :smtp
82+
8883
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
8984
# the I18n.default_locale when a translation cannot be found).
9085
config.i18n.fallbacks = true
9186

92-
# Don't log any deprecations.
93-
config.active_support.report_deprecations = false
94-
9587
# Do not dump schema after migrations.
9688
config.active_record.dump_schema_after_migration = false
9789

@@ -103,19 +95,7 @@
10395
# "example.com", # Allow requests from example.com
10496
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
10597
# ]
106-
98+
#
10799
# Skip DNS rebinding protection for the default health check endpoint.
108100
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
109-
110-
config.action_mailer.smtp_settings = {
111-
port: '587',
112-
address: 'smtp.sendgrid.net',
113-
user_name: ENV['SENDGRID_USERNAME'],
114-
password: ENV['SENDGRID_PASSWORD'],
115-
domain: 'heroku.com',
116-
authentication: :plain,
117-
enable_starttls_auto: true
118-
}
119-
ActionMailer::Base.delivery_method = :smtp
120-
config.action_mailer.default_url_options = { host: 'codebar.io' }
121101
end

config/environments/test.rb

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818
# loading is working properly before deploying your code.
1919
config.eager_load = ENV["CI"].present?
2020

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

24-
# Show full error reports and disable caching.
24+
# Show full error reports.
2525
config.consider_all_requests_local = true
2626

27-
config.action_controller.perform_caching = false
28-
2927
config.cache_store = :null_store
3028

3129
# Render exception templates for rescuable exceptions and raise for other exceptions.
@@ -37,28 +35,17 @@
3735
# Store uploaded files on the local file system in a temporary directory.
3836
config.active_storage.service = :test
3937

40-
# Disable caching for Action Mailer templates even if Action Controller
41-
# caching is enabled.
42-
config.action_mailer.perform_caching = false
43-
4438
# Tell Action Mailer not to deliver emails to the real world.
4539
# The :test delivery method accumulates sent emails in the
4640
# ActionMailer::Base.deliveries array.
4741
config.action_mailer.delivery_method = :test
4842

49-
# Unlike controllers, the mailer instance doesn't have any context about the
50-
# incoming request so you'll need to provide the :host parameter yourself.
43+
# Set host to be used by links generated in mailer templates.
5144
config.action_mailer.default_url_options = { host: "localhost:3000" }
5245

5346
# Print deprecation notices to the stderr.
5447
config.active_support.deprecation = :stderr
5548

56-
# Raise exceptions for disallowed deprecations.
57-
config.active_support.disallowed_deprecation = :raise
58-
59-
# Tell Active Support which deprecation messages to disallow.
60-
config.active_support.disallowed_deprecation_warnings = []
61-
6249
# Raises error for missing translations.
6350
# config.i18n.raise_on_missing_translations = true
6451

config/initializers/assets.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
# Be sure to restart your server when you modify this file.
22

33
# Version of your assets, change this if you want to expire all your assets.
4-
Rails.application.config.assets.version = '1.0'
4+
Rails.application.config.assets.version = "1.0"
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 )
13-
# TODO: consider moving as per upgrade guidance
14-
# https://github.com/rails/sprockets/blob/main/UPGRADING.md#manifestjs
158
Rails.application.config.assets.precompile += %w(payments.js)

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
]

0 commit comments

Comments
 (0)