Skip to content

Commit 0ee51e3

Browse files
committed
Rails 8.1: Rails app:update
1 parent 55d6096 commit 0ee51e3

15 files changed

Lines changed: 247 additions & 32 deletions

bin/ci

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ruby
2+
require_relative "../config/boot"
3+
require "active_support/continuous_integration"
4+
5+
CI = ActiveSupport::ContinuousIntegration
6+
require_relative "../config/ci.rb"

bin/rubocop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require "rubygems"
33
require "bundler/setup"
44

5-
# explicit rubocop config increases performance slightly while avoiding config confusion.
5+
# Explicit RuboCop config increases performance slightly while avoiding config confusion.
66
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
77

88
load Gem.bin_path("rubocop", "rubocop")

bin/setup

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ FileUtils.chdir APP_ROOT do
2222

2323
puts "\n== Preparing database =="
2424
system! "bin/rails db:prepare"
25+
system! "bin/rails db:reset" if ARGV.include?("--reset")
2526

2627
puts "\n== Removing old logs and tempfiles =="
2728
system! "bin/rails log:clear tmp:clear"

config/application.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require_relative "boot"
22

33
require "rails/all"
4-
require "sprockets/railtie"
54

65
# Require the gems listed in Gemfile, including any gems
76
# you've limited to :test, :development, or :production.

config/ci.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Run using bin/ci
2+
3+
CI.run do
4+
step "Setup", "bin/setup --skip-server"
5+
6+
step "Style: Ruby", "bin/rubocop"
7+
8+
step "Security: Importmap vulnerability audit", "bin/importmap audit"
9+
step "Tests: Rails", "bin/rails test"
10+
step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"
11+
12+
# Optional: Run system tests
13+
# step "Tests: System", "bin/rails test:system"
14+
15+
# Optional: set a green GitHub commit status to unblock PR merge.
16+
# Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
17+
# if success?
18+
# step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
19+
# else
20+
# failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
21+
# end
22+
end

config/environments/development.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
# Suppress logger output for asset requests.
6262
config.assets.quiet = true
6363

64+
# Highlight code that triggered redirect in logs.
65+
config.action_dispatch.verbose_redirect_logs = true
66+
6467
# Raises error for missing translations.
6568
# config.i18n.raise_on_missing_translations = true
6669

config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
config.log_tags = [ :request_id ]
4343
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
4444

45-
# Change to "debug" to log everything (including potentially personally-identifiable information!)
45+
# Change to "debug" to log everything (including potentially personally-identifiable information!).
4646
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
4747

4848
# Prevent health checks from clogging up the logs.

config/initializers/content_security_policy.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
2121
# config.content_security_policy_nonce_directives = %w(script-src style-src)
2222
#
23+
# # Automatically add `nonce` to `javascript_tag`, `javascript_include_tag`, and `stylesheet_link_tag`
24+
# # if the corresponding directives are specified in `content_security_policy_nonce_directives`.
25+
# # config.content_security_policy_nonce_auto = true
26+
#
2327
# # Report violations without enforcing the policy.
2428
# # config.content_security_policy_report_only = true
2529
# end
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Be sure to restart your server when you modify this file.
2+
#
3+
# This file eases your Rails 8.1 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.1`.
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+
# Skips escaping HTML entities and line separators. When set to `false`, the
14+
# JSON renderer no longer escapes these to improve performance.
15+
#
16+
# Example:
17+
# class PostsController < ApplicationController
18+
# def index
19+
# render json: { key: "\u2028\u2029<>&" }
20+
# end
21+
# end
22+
#
23+
# Renders `{"key":"\u2028\u2029\u003c\u003e\u0026"}` with the previous default, but `{"key":"

<>&"}` with the config
24+
# set to `false`.
25+
#
26+
# Applications that want to keep the escaping behavior can set the config to `true`.
27+
#++
28+
# Rails.configuration.action_controller.escape_json_responses = false
29+
30+
###
31+
# Skips escaping LINE SEPARATOR (U+2028) and PARAGRAPH SEPARATOR (U+2029) in JSON.
32+
#
33+
# Historically these characters were not valid inside JavaScript literal strings but that changed in ECMAScript 2019.
34+
# As such it's no longer a concern in modern browsers: https://caniuse.com/mdn-javascript_builtins_json_json_superset.
35+
#++
36+
# Rails.configuration.active_support.escape_js_separators_in_json = false
37+
38+
###
39+
# Raises an error when order dependent finder methods (e.g. `#first`, `#second`) are called without `order` values
40+
# on the relation, and the model does not have any order columns (`implicit_order_column`, `query_constraints`, or
41+
# `primary_key`) to fall back on.
42+
#
43+
# The current behavior of not raising an error has been deprecated, and this configuration option will be removed in
44+
# Rails 8.2.
45+
#++
46+
# Rails.configuration.active_record.raise_on_missing_required_finder_order_columns = true
47+
48+
###
49+
# Controls how Rails handles path relative URL redirects.
50+
# When set to `:raise`, Rails will raise an `ActionController::Redirecting::UnsafeRedirectError`
51+
# for relative URLs without a leading slash, which can help prevent open redirect vulnerabilities.
52+
#
53+
# Example:
54+
# redirect_to "example.com" # Raises UnsafeRedirectError
55+
# redirect_to "@attacker.com" # Raises UnsafeRedirectError
56+
# redirect_to "/safe/path" # Works correctly
57+
#
58+
# Applications that want to allow these redirects can set the config to `:log` (previous default)
59+
# to only log warnings, or `:notify` to send ActiveSupport notifications.
60+
#++
61+
# Rails.configuration.action_controller.action_on_path_relative_redirect = :raise
62+
63+
###
64+
# Use a Ruby parser to track dependencies between Action View templates
65+
#++
66+
# Rails.configuration.action_view.render_tracker = :ruby
67+
68+
###
69+
# When enabled, hidden inputs generated by `form_tag`, `token_tag`, `method_tag`, and the hidden parameter fields
70+
# included in `button_to` forms will omit the `autocomplete="off"` attribute.
71+
#
72+
# Applications that want to keep generating the `autocomplete` attribute for those tags can set it to `false`.
73+
#++
74+
# Rails.configuration.action_view.remove_hidden_field_autocomplete = true

config/puma.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#
88
# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
99
# should only set this value when you want to run 2 or more workers. The
10-
# default is already 1.
10+
# default is already 1. You can set it to `auto` to automatically start a worker
11+
# for each available processor.
1112
#
1213
# The ideal number of threads per worker depends both on how much time the
1314
# application spends waiting for IO operations and on how much you wish to
@@ -33,7 +34,7 @@
3334
# Allow puma to be restarted by `bin/rails restart` command.
3435
plugin :tmp_restart
3536

36-
# Run the Solid Queue supervisor inside of Puma for single-server deployments
37+
# Run the Solid Queue supervisor inside of Puma for single-server deployments.
3738
plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
3839

3940
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
@@ -45,4 +46,4 @@
4546
# Silence Puma output in test environment
4647
if ENV.fetch("RAILS_ENV", "development") == "test"
4748
quiet
48-
end
49+
end

0 commit comments

Comments
 (0)