LoginSignup
0
0

More than 3 years have passed since last update.

Railsのform_withはデフォルトでAjax通信をする

Posted at

生じた現象

  • formを入力してPOST送信をして返ってきたレスポンスのHTMLが、ブラウザでレンダリングされなかった。

対策


form_with(model: @form, local: true) do |f|
   # inputたち
end

のように、local: true指定してやれば良い。

参考

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.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0