[solved] Agile Web Development with Rails 8: Locale switches back to default on order form error (B3, PDF p. 244)

The form_with helper for orders/_form.html.erb needs to have a url: parameter with the current locale or else the form will be submitted without a locale parameter and it might default back to English. (The behavior of the locale is kind of flaky and can bleed between requests if you use I18n.locale = instead of I18n.with_locale)

This is what’s in the book:
<%= form_with(model: order, class: "contents") do |form| %>

this is what is needed to avoid flakiness and locale resets:
<%= form_with(model: order, class: "contents", url: orders_path(locale: I18n.locale)) do |form| %>