3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

formボタンを押しても動かない際の対処法【原因はturbolinks・<div class="actions">】

Last updated at Posted at 2020-04-13

こちらの記事の通りでした。
https://qiita.com/d0ne1s/items/5a4122d2972be3812986

備忘録としてtturbolinksの無効化方法を自分用にメモします。

環境
Rails6.2.0

###Gemを削除し、bundleupdateする

#gem 'turbolinks', '~> 5'
$ bundle update

###application.jsを編集する

app/assets/javascripts/application.js
//= require turbolinks #この行を削除

###2箇所の'data-turbolinks-track': 'reload'の部分を削除する

app/views/layouts/application.html.erb
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>

<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

###formを編集する

form_withを使って作成したformがある場合、全てのformにlocal:trueオプションをつける必要があります。

###これでも動かない際の対処

<div class="actions"></div> でformボタンを囲んだところ、うまく動く場合があります。

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?