0
0

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.

[Rails] has_many関連を操作するためのフォームで collection_check_box が使えないときに _destroy 属性を使ってチェックボックスを作る時にはvalueを反転させてやると良い

Last updated at Posted at 2020-12-03

Railsでaccepts_nested_attributes :hoge, allow_destroy: truehas_many関連を操作したい時にcollection_check_boxを使うことがよくありますが、諸事情でこれが使えない時に、ff.check_box :_destroy, {}, '0', '1'_destroy属性のチェックボックスをvalueの値を反転させて作ってやるとよい。
思いつけば単純なのですがハマって時間かかってしまったのでメモ。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?