8000 Fix: Use PATCH method for onboarding preferences form by alvaro-rrdt · Pull Request #2399 · maybe-finance/maybe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Use PATCH method for onboarding preferences form #2399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alvaro-rrdt
Copy link

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: :patch on the form_with helper to ensure the correct verb is always used, resolving the routing error for all new users.

Fixes #2398

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: :patch` on the form_with helper
to ensure the correct verb is always used, resolving the routing error
for all new users.

Fixes maybe-finance#2398
@@ -63,7 +63,7 @@

<p class="text-secondary text-xs mb-4"><%= t(".preview") %></p>

<%= styled_form_with model: @user, data: { turbo: false } do |form| %>
<%= styled_form_with model: @user, method: :patch, data: { turbo: false } do |form| %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I'm not mistaken, Rails should already be submitting a PUT request since the @user exists 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?

Copy link
Author

Choose a reason for hiding this comment

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [Onboarding form submits with POST, expects PATCH]
2 participants
0