This is a redirect from my log, but page doesn’t change I’m still on the same page containing the form I submitted
127.0.0.1 - - [14/Feb/2020:11:55:46 EST] “GET /artists/72/press_releases HTTP/1.1” 200 2542
http://localhost:3000/artists/72/tours/1 → /artists/72/press_releases
Is your form set to the default of an Ajax submission, or did you add the configuration flag to the form_with method call that makes it actually redirect? If this was a redirect, the header would be 301, not 200.
Well I hope you’re still with me on this cause I solved it and I don’t have anyone else to tell For some reason I had commented out
gem turbolinks in my Gemfile I’m upgrading all my apps to rails 6 and really to webpacker I remember reading somewhere the new way of doing things is to not use turbolinks I don’t remember where
“remote: false” with “local: true” and tell me if that works for you.
Source: I wrote the docs on form_with.
Did that solution work for you?
With all due respect, if you “wrote the docs on form_with,” I would refer you to my previous thread in which I am complaining about Turbolinks being default (I think it shouldn’t be).
You will also note that the only place local: true appears on the form_with documentation is in a “red alert” box, as if it is a side-note or “extra information,” and you have to read through almost half of the entire document to find this obscure yet vital piece of information.
For something that makes Rails basically non-usable as a modern web framework out-of-the-box, I seriously think you should consider that the ‘local: true’ information and all this easy casual encouragement for newbies to “just skip turbolinks this way” (which is a fine choice if you know what you’re doing) is somewhat careless.
Either of 3 things should happen here:
If this is so non-intuitive it should be much more prominent in the docs than it is. Like, top -of-page prominent. Why are there separate settings for ‘local: true’ and ‘remote: true’ anyway? Doesn’t that confuse anybody else. Why wouldn’t you simply pass ‘remote: false’ (which doesn’t currently work) and do-away with another setting to remember?
Turbolinks should be removed as the default for rails and should be an opt-in technology like many other things which once were in Rails core and now aren’t. There’s just too many devs turning it off left & right and too many people getting stuck and slowed down by it to justify it staying as the default.
If new entrants are coming to the Rails framework, it needs to be explained to them this is an advanced complicated framework and in order to get basics to work you need to understand how to bind Ajax events. It is no longer a ‘minutes to learn’ framework as it was when it was invented and this is a perfect example of the barriers to entry that we are putting up for new entrants.
(you’ll note my preference because it is in boldface above)