Rails form_with communicates Ajax by default

The phenomenon that occurred

--The HTML of the response returned by inputting the form and sending a POST was not rendered in the browser.

Countermeasures


form_with(model: @form, local: true) do |f|
   #inputs
end

You can specify local: true like this.

reference

--According to https://stackoverflow.com/a/50647776,

Forms generated with form_with by default has data-remote set to true. If the data-remote is set to true your form makes an AJAX call. So your view is getting rendered as the response of that AJAX call. That is why you are not getting any errors. Add local: true in your form_with.

Recommended Posts

Rails form_with communicates Ajax by default
[Rails] form_with
Delve into Rails form_with
[Rails] Completely understand form_with
Ajax bookmark function using Rails
Rails singular resource routing by resource