3
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 5 years have passed since last update.

Ruby on Railsで"can't quote Array"のエラーが出た場合

Posted at

model中以下のコマンドにおいて"can't quote Array"のエラーが出たので自分用メモ
self.update_column(:before_group_ids, before_group_ids)

原因調査

調べたページ

試した対応(効果なし)

  • migrationにおいてdefault: [].to_yamlを入れる => 効果なし
  • migrationにおいてdefault: [], array:trueを入れる => 効果なし
  • self.before_group_ids = [0,1] + self.save => 成功
  • self.update_attribute(:before_group_ids, before_group_ids) => 成功

解決

ひとまずupdate_attributeを用いることでエラー回避
update_columnはUPDATE SQLを作成してとあるように、
active_recordを挟まないためエラーが出ていたのかな...?

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