Fix: Use PATCH method for onboarding preferences form #2399
Reference in New Issue
Block a user
Delete Branch "fix/onboarding-form-method"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The form on the user onboarding preferences page was submitting with the POST HTTP method, which caused an ActionController::RoutingError because the /users/:id route only accepts PATCH/PUT for updates.
This appeared to be a state-related bug where form_with was not correctly inferring the method from the persisted @user object during the initial onboarding flow.
This change explicitly sets
method: :patchon the form_with helper to ensure the correct verb is always used, resolving the routing error for all new users.Fixes #2398
@@ -65,3 +65,3 @@<%= styled_form_with model: @user, data: { turbo: false } do |form| %><%= styled_form_with model: @user, method: :patch, data: { turbo: false } do |form| %><%= form.hidden_field :set_onboarding_preferences_at, value: Time.current %>If I'm not mistaken, Rails should already be submitting a PUT request since the
@userexists already and is not a new record. I'm not actually able to reproduce the original error either, so I'm wondering if there is an unrelated bug going on instead?@@ -65,3 +65,3 @@<%= styled_form_with model: @user, data: { turbo: false } do |form| %><%= styled_form_with model: @user, method: :patch, data: { turbo: false } do |form| %><%= form.hidden_field :set_onboarding_preferences_at, value: Time.current %>Might be, I didn't went back and rebuild the DB and the data after I found such issue I quickly drafted a solution and continued the onboarding process, when I posted this bug report I also thought it was some kind of one time issue and it was weird for me as well, good that you were not able to reproduce it though.
Zach, check your mail when you can please I sent you a mail
@@ -65,3 +65,3 @@<%= styled_form_with model: @user, data: { turbo: false } do |form| %><%= styled_form_with model: @user, method: :patch, data: { turbo: false } do |form| %><%= form.hidden_field :set_onboarding_preferences_at, value: Time.current %>Gotcha, I'm going to close out this PR and the corresponding issue for now as I don't think we've got a bug, but happy to reopen in the future if we can reproduce it more reliably!
Pull request closed