Reputation: 329
I have my application running Ruby on Rails 6. Like any other application, I have some forms too. When I submit the form with any error, the URL gets replaced with form action and now when I reload the page I get route error -
No route matches [GET] "/admins/password"
Usually when we reload page after form submit with errors, The browser asks if we want to resubmit the form. But in my case this is not happening. This is a basic stuff but no idea what is going wrong.
Upvotes: 0
Views: 370
Reputation: 329
This is what I found really helpful regarding my question. https://github.com/turbolinks/turbolinks/issues/60
Upvotes: 1
Reputation: 624
try to insert event.preventDefault()
on your onsubmit
event handler function. If you post some code would be helpful.
Easy code would be:
document.querySelector("#myform").onsubmit = function(event){
// ...check for errors
if(errors){
event.preventDefault();
}
}
Upvotes: 0