Skip to content

Upgrade Rails from 7.2 to 8.0#6955

Open
stefannibrasil wants to merge 20 commits into
rubyforgood:mainfrom
hexdevs:upgrade-to-rails-8.0
Open

Upgrade Rails from 7.2 to 8.0#6955
stefannibrasil wants to merge 20 commits into
rubyforgood:mainfrom
hexdevs:upgrade-to-rails-8.0

Conversation

@stefannibrasil
Copy link
Copy Markdown
Contributor

@stefannibrasil stefannibrasil commented May 20, 2026

What github issue is this PR for, if any?

Closes #6925

What changed, and why?

Rails 8.0 was released in late 2024 and brings Solid Queue / Solid Cache / Solid Cable as defaults, Propshaft, Kamal 2, Authentication generator, and a number of framework deprecations.

Most notable changes:

  • It's not possible to use only and except for non-RESTful routes: c64228a
  • I removed comments and configs from previous upgrades, and updated config/environments with the generated files as much as possible
  • I couldn't find out exactly where this changed in the release notes for this Rails version but I imagine it's a good change since it shows the new 404 page instead of raising a server error: c5af932
  • The new defaults from config/initializers/new_framework_defaults_8_0.rb look okay to be enabled altogether but if you prefer to enable them individually, let me know.
  • The 406 and 422 error pages have a new generated UI:
Screenshot 2026-05-15 at 12 11 29 PM Screenshot 2026-05-15 at 12 07 35 PM

How is this tested? (please write rspec and jest tests!) 💖💪

  • tested the app locally
  • running tests
  • CI is passing

Followups

  • Once Rails 8 is up and running, we can later update the config.load_defaults to 8.0. It should fix this deprecation warning: "DEPRECATION WARNING: to_time will always preserve the full timezone rather than offset of the receiver in Rails 8.1. To opt in to the new behavior, set config.active_support.to_time_preserves_timezone = :zone. (called from <top (required)> at /home/runner/work/casa/casa/config/environment.rb:5)"
  • It's possible to upgrade from Sprockets to Propshaft: https://github.com/rails/propshaft/blob/main/UPGRADING.md

Questions

Is it possible to test this on staging/QA first? Please try this out locally and let me know if you run into any issues.

@github-actions github-actions Bot added 🧪 Tests Tests dependencies Touches dependency files ruby Touches Ruby code labels May 20, 2026
@compwron
Copy link
Copy Markdown
Collaborator

cooollll :)

@stefannibrasil stefannibrasil force-pushed the upgrade-to-rails-8.0 branch from 4d12204 to c5af932 Compare May 20, 2026 21:26
@stefannibrasil stefannibrasil force-pushed the upgrade-to-rails-8.0 branch from 5eb704c to d37e734 Compare May 20, 2026 21:39
Comment thread bin/dev

foreman start -f Procfile.dev "$@"
#!/usr/bin/env ruby
exec "./bin/rails", "server", *ARGV
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested things locally and this seems fine. Could someone try it out and see if it's best to keep the previous changes?

# If set to `:zone`, `to_time` methods will use the timezone of their receivers.
# If set to `:offset`, `to_time` methods will use the UTC offset.
# If `false`, `to_time` methods will convert to the local system UTC offset instead.
#++
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new defaults look okay to be enabled altogether...

Comment thread config/routes.rb
end
end
resources :reimbursements, only: %i[index change_complete_status], concerns: %i[with_datatable] do
resources :reimbursements, only: %i[index], concerns: %i[with_datatable] do
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See rails/rails#51464

I tested the removed routes and they work as expected.

@@ -1,6 +1,4 @@
require "rails_helper"
# require "contact_type_group"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was left here from the previous upgrade, but it's not necessary anymore.

it "raises RoutingError if no step in url" do
expect { patch "/case_contacts/#{case_contact.id}/form", params: {case_contact: attributes} }
.to raise_error(ActionController::RoutingError)
it "responds with 404 if no step in url" do
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find out exactly where this changed in the release notes for this Rails version but I imagine it's a good change since it shows the new 404 page instead of raising a server error.

@stefannibrasil stefannibrasil changed the title Upgrade to rails 8.0 Upgrade Rails from 7.2 to 8.0 May 20, 2026
@stefannibrasil stefannibrasil marked this pull request as ready for review May 20, 2026 22:19
@stefannibrasil
Copy link
Copy Markdown
Contributor Author

@compwron could you test this branch locally and in staging as well? I want to make sure I am not introducing anything that I couldn't test locally. Thanks!

@compwron
Copy link
Copy Markdown
Collaborator

very cool, will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Touches dependency files ruby Touches Ruby code 🧪 Tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade Rails from 7.2 to 8.x

2 participants