Skip to content

Commit 5c9062f

Browse files
authored
feat: target Rails 8.0 and require at least Ruby 3.2 (#601)
Closes #589 Resolves #588 Resolves #587 Closes #586 Closes #573 Resolves #570 Resolves #569
1 parent 3290224 commit 5c9062f

File tree

8 files changed

+56
-59
lines changed

8 files changed

+56
-59
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ jobs:
184184
# "react", "sidekiq" etc.
185185
APP_NAME: ${{ matrix.variant.name }}-demo
186186
CONFIG_PATH: ${{ matrix.variant.config_path }}
187-
SKIPS: '--skip-javascript --skip-docker ${{ matrix.variant.skips }}'
187+
# prettier-ignore
188+
SKIPS: '--skip-javascript --skip-docker --skip-kamal --skip-solid ${{ matrix.variant.skips }}'
188189
PGUSER: postgres
189190
PGPASSWORD: postgres
190191
PGHOST: localhost

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ $ wget https://raw.githubusercontent.com/ackama/rails-template/main/ackama_rails
193193

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

198198
# Example 2
199199
# #########
200200

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

203203
# Template options will be taken from ../my_custom_config.yml (relative to the new app directory)
204-
$ 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
204+
$ CONFIG_PATH=../my_custom_config.yml rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --skip-kamal --skip-solid --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
205205
```
206206

207207
Here are some additional options you can add to this command. We don't
@@ -230,6 +230,8 @@ To make this the default Rails application template on your system, create a
230230
-d postgresql
231231
--skip-javascript
232232
--skip-docker
233+
--skip-kamal
234+
--skip-solid
233235
-m https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
234236
```
235237

ci/bin/build-and-test

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

3535
config_env_var = %Q(CONFIG_PATH="#{config_path}") if config_path
36-
skip_flags = ENV.fetch("SKIPS", "--skip-javascript --skip-docker")
36+
skip_flags = ENV.fetch("SKIPS", "--skip-javascript --skip-docker --skip-kamal --skip-solid")
3737

3838
puts "=" * 80
3939
puts <<~EO_CONFIG_SUMMARY

target_versions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# This is stored in a separate file so we can share it between the template and
44
# our CI configuration.
5-
target_rails_major_minor: '7.2' # specify as major.minor
5+
target_rails_major_minor: '8.0' # specify as major.minor
66

77
# Set this to the minimum version of Ruby that the chosen Rails version supports.
8-
minimum_ruby_major_minor: '3.1'
8+
minimum_ruby_major_minor: '3.2'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file must exist for assets pipeline compatibility.

variants/backend-base/app/template.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Configure app/assets
2+
copy_file "variants/backend-base/app/assets/config/manifest.js", "app/assets/config/manifest.js"
3+
14
# Configure app/controllers
25
copy_file "variants/backend-base/app/controllers/home_controller.rb", "app/controllers/home_controller.rb"
36
copy_file "variants/backend-base/app/controllers/active_storage/base_controller.rb", "app/controllers/active_storage/base_controller.rb"
@@ -29,3 +32,8 @@
2932
# allow_browser versions: :modern
3033
AFTER
3134
)
35+
36+
remove_dir ".github/"
37+
remove_dir "app/views/pwa"
38+
remove_file "bin/dev"
39+
remove_file "bin/thrust"

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

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,48 @@
11
gsub_file! "config/environments/production.rb",
2-
"# config.assets.css_compressor = :sass",
3-
<<-RUBY
4-
#
5-
# Currently disabled as minification adds a *huge* amount of time to precompile,
6-
# and gzip alone already gets us about 70% of the benefits of minify+gzip
7-
config.assets.css_compressor = false
8-
RUBY
2+
"config.assume_ssl = true",
3+
<<~RUBY
4+
#
5+
# You should never use this because it just blindly sets headers without any actual
6+
# checks; instead, whatever is handling the SSL-termination should be setting the
7+
# appropriate headers to indicate that the request was actually SSL-terminated.
8+
config.assume_ssl = false
9+
RUBY
910

1011
gsub_file! "config/environments/production.rb",
1112
"config.force_ssl = true",
1213
<<~RUBY
13-
##
14-
# `force_ssl` defaults to on. Set `force_ssl` to false if (and only if) RAILS_FORCE_SSL=false, otherwise set it to true.
1514
#
15+
# On by default, though can be disabled by setting RAILS_FORCE_SSL=false (and only "false")
1616
config.force_ssl = ENV.fetch("RAILS_FORCE_SSL", "true").downcase != "false"
1717
RUBY
1818

1919
gsub_file! "config/environments/production.rb",
2020
"# config.action_mailer.raise_delivery_errors = false",
21-
<<-RUBY
22-
config.action_mailer.raise_delivery_errors = true
21+
"config.action_mailer.raise_delivery_errors = true"
2322

24-
config.action_mailer.default_url_options = {
25-
host: "#{TEMPLATE_CONFIG.production_hostname}",
26-
protocol: "https"
27-
}
28-
config.action_mailer.asset_host = "https://#{TEMPLATE_CONFIG.production_hostname}"
23+
gsub_file! "config/environments/production.rb",
24+
'config.action_mailer.default_url_options = { host: "example.com" }',
25+
<<~RUBY
26+
config.action_mailer.default_url_options = {
27+
host: "#{TEMPLATE_CONFIG.production_hostname}",
28+
protocol: "https"
29+
}
2930
31+
config.action_mailer.asset_host = "https://#{TEMPLATE_CONFIG.production_hostname}"
32+
RUBY
33+
gsub_file! "config/environments/production.rb",
34+
<<-RUBY,
35+
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
36+
# config.action_mailer.smtp_settings = {
37+
# user_name: Rails.application.credentials.dig(:smtp, :user_name),
38+
# password: Rails.application.credentials.dig(:smtp, :password),
39+
# address: "smtp.example.com",
40+
# port: 587,
41+
# authentication: :plain
42+
# }
43+
RUBY
44+
<<-RUBY
45+
# Specify outgoing SMTP server.
3046
config.action_mailer.smtp_settings = {
3147
address: ENV.fetch("SMTP_HOSTNAME"),
3248
port: ENV.fetch("SMTP_PORT", 587),
@@ -43,43 +59,12 @@
4359
'ENV.fetch("RAILS_LOG_LEVEL", ENV.fetch("LOG_LEVEL", "info"))'
4460

4561
gsub_file! "config/environments/production.rb",
46-
"ActiveSupport::Logger.new(STDOUT)",
47-
"ActiveSupport::Logger.new($stdout)"
48-
49-
insert_into_file! "config/environments/production.rb",
50-
after: /.*config\.public_file_server\.enabled.*\n/ do
51-
<<~'RUBY'
62+
"ActiveSupport::TaggedLogging.logger(STDOUT)",
63+
"ActiveSupport::TaggedLogging.logger($stdout)"
5264

53-
# Ensure that Rails sets appropriate caching headers on static assets if
54-
# Rails is serving static assets in production e.g. on Heroku
55-
#
56-
# Overview of Cache-control values:
57-
#
58-
# max-age=<seconds>
59-
# The maximum amount of time a resource is considered fresh.
60-
#
61-
# s-maxage=<seconds>
62-
# Overrides max-age or the Expires header, but only for shared
63-
# caches (e.g., proxies). Ignored by private caches.
64-
#
65-
# More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
66-
#
67-
# Our Cache-Control header:
68-
#
69-
# * It tells all caches (both proxies like Cloudflare and the users web
70-
# browser) that the asset can be cached.
71-
# * It tells shared caches (e.g. Cloudflare) that they can cache it for 365 days
72-
# * It tells browsers that they should cache for 365 days
73-
#
74-
# Cloudflare will respect s-maxage if it is set so change that value if you
75-
# want Cloudflare to cache differently than then browser.
76-
#
77-
config.public_file_server.headers = {
78-
"Cache-Control" => "public, s-maxage=#{365.days.seconds}, max-age=#{365.days.seconds}"
79-
}
80-
81-
RUBY
82-
end
65+
gsub_file! "config/environments/production.rb",
66+
"config.silence_healthcheck_path =",
67+
"# config.silence_healthcheck_path ="
8368

8469
insert_into_file! "config/environments/production.rb",
8570
after: /.*config.cache_store = :mem_cache_store\n/ do

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
end
1111

1212
gsub_file! "config/environments/test.rb",
13-
'config.action_mailer.default_url_options = { host: "www.example.com" }',
13+
'config.action_mailer.default_url_options = { host: "example.com" }',
1414
'config.action_mailer.default_url_options = { host: "localhost:3000" }'
1515

1616
gsub_file! "config/environments/test.rb",

0 commit comments

Comments
 (0)