When I started a new project in Rails 7 and copy code from previous project, I encountered the several problems. For example, for login page, if password is wrong, the page doesn't show errors. For signup, similarly, it doesn't show any error messages.
I found JS console error
responses must redirect to another location
Then I found the articles 1 & 2
Here is why:
Turbo
replaced Turbolinks
. format.html { render :signup } # same page
format.html { flash[:error] = "ERROR" } # same page, no redirect
There are two solutions:
format.html { render :signup, status: :unprocessable_entity}
format.html { flash[:error] = "ERROR"; redirect_to({action: :login})} # redirect to itself.
turbo_frame_tag