Post an empty message.
The server does what a lot of Rails code does on a validation failure: render :index with the errors, status 200. Watch: the response arrives, and Turbo ignores it. The page doesn't change. The console explains.
Place your bet before you read on: why would Turbo refuse a perfectly good HTML response?
After a POST, a 200 has to be a redirect.
If Turbo rendered that 200, the page would be sitting at a URL that was reached by POST. A refresh would re-POST, and browsers show the "resubmit form?" dialog for exactly that reason. Turbo can't replicate that dialog, so it refuses the situation instead. (303 rather than 302 because a 303 always means "now GET this", even after a PATCH or DELETE.)
Errors are still allowed to render. They just have to say they're errors:
if @message.save
redirect_to messages_path, status: :see_other # 303
else
render :new, status: :unprocessable_content # 422
end
Flip the server to 422 and post empty again. The page renders with the errors, and the URL stays put.
Small things Turbo does to forms.
- The submitter is disabled from
turbo:submit-starttoturbo:submit-end. No double posts.data-turbo-submits-with="Saving…"swaps its label meanwhile. data-turbo-confirmon a form or adata-turbo-methodlink asks first. Replace the browser dialog withTurbo.config.forms.confirm = yourFunction.- GET forms (search boxes) navigate like links. Point one at a frame with
data-turbo-frameand it filters in place; adddata-turbo-action="advance"to put the query in the URL.