LoginSignup
0
0

More than 5 years have passed since last update.

【Rails5.2.1】form_for内のbuttonでjs.erbが読み込まれない

Posted at

開発環境

  • rails 5.2.1
  • ruby 2.5.0

問題点

表題の通り、form_forのbuttonにremote:trueを付与してpost通信してもjs.erbが読み込まれませんでした。
下記がその時のコードです。

    <%= form_for :model, url: @url do |form| %>
      <%= form.button "投稿する", :action => "create", remote:true %>
    <% end %>

解決策

上部のform_forの定義の部分でremote:trueを指定してあげればjs.erbが読み込まれました。

    <%= form_for :model, url: @url, remote:true do |form| %>
      <%= form.button "投稿する", :action => "create", remote:true %>
    <% end %>
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