Rails 7: Form Errors Disappear on Failed Validation

I’m using Rails 7 - very vanilla and used rails g scaffold. When a form submission fails validation, I’m seeing this behavior:

The errors for that form don’t show up because of the GET ‘new’ happening there resets the @user object from current_user.

I created a fresh Rails 7 app and scaffolded the same model, and the error shows up fine there.

How can I best figure out what’s causing this problem?

My form looks like this, just like the one generated by rails g scaffold.

<%= form_with(model: @bank_account, class: "contents") do |form| %>

This seems highly related. Am I seeing this bug because I’m using the Devise gem for auth? What can I do?

Rendering a view after form submission not working correctly in Rails 7 - Stack Overflow

I just did a fresh rails g scaffold Post title:text within my project.

In my network tools here’s the form post (fetch) and the get request to the new action.

I’m trying to figure out what causes the pageInvalidated being called which then calls reload.

Alright I found the problem. I had a partial for Google Tag Manager in my <head> and that was the wrong place for it be in.

<noscript>
  <iframe
    src="https://www.googletagmanager.com/ns.html?id=123123123"
    height="0"
    width="0"
    style="display:none;visibility:hidden"
  >
  </iframe>
</noscript>

Moving it down into the <body> fixed the problem.