Skip to content

Commit 62446f3

Browse files
G-Ratheoinkelly
andauthored
feat: support Rails 7.1 (#502)
Resolves #500 This aims to be the minimal changes required for the template to work with Rails 7.1 ### Things which are not in scope for this PR * Rails now generates docker related files - I've forced/skipped those because their docker is focused on production and the diff is quite large so I think it's best to tackle that as its own separate thing ### TODO - [x] Do the basic upgrade - [x] Adjust `frontend-base` to account for Shakapacker now doing a thing we previously did ourselves. - [x] `Rack::Handler is deprecated and replaced by Rackup::Handler` warning. This appears during system tests. It is a knownw [Capybara issue which is fixed but waiting on a gem release](teamcapybara/capybara#2706). Since this is just a warning and will go away in due course, we can ignore it. - [x] Resolve `Setting 'useContentHash' to 'false' in the production environment (specified by NODE_ENV environment variable) is not allowed! Content hashes get added to the filenames regardless of setting useContentHash in 'shakapacker.yml' to false.` warning. This warning seems to caused by the default `shakapacker.yml`. Shakapacker generates a `shakapacker.yml` file where `useContentHash: false` is set in the `&default` section and then `useContentHash: true` is explicitly set in the production section. It doesn't seem like a real problem so I think we can ignore this. - [x] Make a decision about #507 and implement it here - We have decided to leave this option commented out for now. - [ ] Make a decision about how to handle the `Rails.application.secrets` deprecation because it will be removed in 7.2. #341 has good context on the last time we discussed this. --------- Co-authored-by: Eoin Kelly <eoin@eoinkelly.info> Co-authored-by: Eoin Kelly <eoin.kelly@ackama.com>
1 parent 332b6c2 commit 62446f3

File tree

10 files changed

+23
-19
lines changed

10 files changed

+23
-19
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,8 @@ jobs:
150150
# "react", "sidekiq" etc.
151151
APP_NAME: ${{ matrix.variant.name }}-demo
152152
CONFIG_PATH: ${{ matrix.variant.config_path }}
153-
SKIPS: "--skip-javascript ${{ matrix.variant.skips }}"
153+
SKIPS: "--skip-javascript --skip-docker ${{ matrix.variant.skips }}"
154154
PGUSER: postgres
155155
PGPASSWORD: postgres
156156
PGHOST: localhost
157-
RAILS_SECRET_KEY_BASE: "placeholder"
158-
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: "placeholder"
159-
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: "placeholder"
160-
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: "placeholder"
161157
run: ./ci/bin/build-and-test

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Before running this template, you must have the following installed on your
155155
machine:
156156

157157
- Yarn v1.21.0 or later
158-
- Rails 7.0.x
158+
- Rails 7.1.x
159159

160160
The following are not strictly required to run the template but you will need it
161161
to start the Rails app that this template creates:
@@ -192,15 +192,15 @@ $ wget https://raw.githubusercontent.com/ackama/rails-template/main/ackama_rails
192192

193193
# Create a new app using the template. Template options will be taken from
194194
# ./ackama_rails_template.config.yml
195-
$ rails new my_app --no-rc --database=postgresql --skip-javascript --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
195+
$ rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
196196

197197
# Example 2
198198
# #########
199199

200200
# Create a custom config YAML file, saving as ./my_custom_config.yml
201201

202202
# Template options will be taken from ../my_custom_config.yml (relative to the new app directory)
203-
$ CONFIG_PATH=../my_custom_config.yml rails new my_app --no-rc --database=postgresql --skip-javascript --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
203+
$ CONFIG_PATH=../my_custom_config.yml rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
204204
```
205205

206206
Here are some additional options you can add to this command. We don't
@@ -228,6 +228,7 @@ To make this the default Rails application template on your system, create a
228228
# ~/.railsrc
229229
-d postgresql
230230
--skip-javascript
231+
--skip-docker
231232
-m https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
232233
```
233234

@@ -275,7 +276,7 @@ $ CONFIG_PATH="ci/configs/react.yml" APP_NAME="enterprise" ./ci/bin/build-and-te
275276
# because the template is run by `rails new` which uses the rails app dir as
276277
# it's working dir, hence the `../` at the start.
277278
#
278-
$ rm -rf mydemoapp && CONFIG_PATH="../ci/configs/react.yml" rails new mydemoapp -d postgresql --skip-javascript -m ./template.rb
279+
$ rm -rf mydemoapp && CONFIG_PATH="../ci/configs/react.yml" rails new mydemoapp -d postgresql --skip-javascript --skip-docker -m ./template.rb
279280
```
280281

281282
Rubocop is configured for this repo and is run as part of CI. Run rubocop

ci/bin/build-and-test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ config_path = if ENV.fetch("CONFIG_PATH", "") == ""
1515
end
1616

1717
config_env_var = %Q(CONFIG_PATH="#{config_path}") if config_path
18-
skip_flags = ENV.fetch("SKIPS", "--skip-javascript")
18+
skip_flags = ENV.fetch("SKIPS", "--skip-javascript --skip-docker")
1919

2020
puts "=" * 80
2121
puts <<~EO_CONFIG_SUMMARY

template.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require "shellwords"
33
require "pp"
44

5-
RAILS_REQUIREMENT = "~> 7.0.3".freeze
5+
RAILS_REQUIREMENT = "~> 7.1.1".freeze
66

77
##
88
# This single template file will be downloaded and run by the `rails new`
@@ -92,10 +92,10 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met
9292

9393
copy_file "variants/backend-base/.node-version", ".node-version"
9494

95-
copy_file "variants/backend-base/Dockerfile", "Dockerfile"
95+
copy_file "variants/backend-base/Dockerfile", "Dockerfile", force: true
9696
copy_file "variants/backend-base/docker-compose.yml", "docker-compose.yml"
9797
copy_file "variants/backend-base/.osv-detector.yml", ".osv-detector.yml"
98-
copy_file "variants/backend-base/.dockerignore", ".dockerignore"
98+
copy_file "variants/backend-base/.dockerignore", ".dockerignore", force: true
9999

100100
apply "variants/backend-base/Rakefile.rb"
101101
apply "variants/backend-base/config.ru.rb"
@@ -304,6 +304,7 @@ def assert_valid_options
304304
skip_test_unit: true,
305305
skip_active_storage: false,
306306
skip_javascript: true,
307+
skip_docker: true,
307308
edge: false
308309
}
309310
valid_options.each do |key, expected|

variants/audit-logging/template.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source_paths.unshift(File.dirname(__FILE__))
22

3-
copy_file("variants/audit-logging/lib/auditor_log_formatter.rb", "lib/auditor_log_formatter.rb")
3+
copy_file("variants/audit-logging/lib/audit_log_log_formatter.rb", "lib/audit_log_log_formatter.rb")
44
copy_file("variants/audit-logging/services/audit_log.rb", "app/services/audit_log.rb")
55
copy_file("variants/audit-logging/spec/services/audit_log_spec.rb", "spec/services/audit_log_spec.rb")
66

@@ -19,7 +19,7 @@
1919

2020
prepend_to_file "config/application.rb" do
2121
<<~RUBY
22-
require_relative "../lib/auditor_log_formatter"
22+
require_relative "../lib/audit_log_log_formatter"
2323
RUBY
2424
end
2525

variants/backend-base/app/views/layouts/application.html.erb.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<title>
5-
<%%= strip_tags(yield(:title)) + " " if content_for?(:title) %>
5+
<%%= strip_tags(yield(:title)) + " - " if content_for?(:title) %>
66
<%= app_const_base.titleize %>
77
</title>
88

@@ -15,7 +15,7 @@
1515
<%%= stylesheet_link_tag("application", media: "all", "data-turbolinks-track": "reload") %>
1616

1717
<%%# JavaScript must be in head for Turbolinks to work. %>
18-
<%%= javascript_pack_tag "application", "data-turbolinks-track": "reload", defer: true %>
18+
<%%= javascript_pack_tag "application", "data-turbolinks-track": "reload", defer: true, nonce: true %>
1919

2020
<%%= yield(:head) %>
2121

variants/backend-base/config/environments/development.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
gsub_file "config/environments/development.rb",
1919
"join('tmp', 'caching-dev.txt')",
2020
'join("tmp/caching-dev.txt")'
21+
22+
gsub_file "config/environments/development.rb",
23+
"config.action_controller.raise_on_missing_callback_actions = true",
24+
"# config.action_controller.raise_on_missing_callback_actions = true"

variants/backend-base/config/environments/test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@
1616
config.i18n.raise_on_missing_translations = true
1717
RUBY
1818
end
19+
20+
gsub_file "config/environments/test.rb",
21+
"config.action_controller.raise_on_missing_callback_actions = true",
22+
"# config.action_controller.raise_on_missing_callback_actions = true"

variants/frontend-base/template.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
# Configure app/frontend
2626

2727
run "mv app/javascript app/frontend"
28-
run "mkdir app/frontend/packs"
29-
run "mv app/frontend/application.js app/frontend/packs/application.js"
3028

3129
copy_file "config/webpack/webpack.config.js", force: true
3230

0 commit comments

Comments
 (0)