LoginSignup
0
0

More than 3 years have passed since last update.

ransackで#Array:〜〜のエラー

Posted at

問題

配列処理したいが、以下のエラーが発生する。

#[Array:0x00007f55f06941f8](array:0x00007f55f06941f8)

原因

Arrayクラスになっているのが原因

ransackではActiveRecord_Relationクラスにする必要がある。

解決策

where、mapをつかい、Array→ActiveRecord_Relationクラスに変換する

.where(id: items.map{ |item| [item.id](http://item.id/) })

参考サイト

配列をActiveRecord::Relationで再取得するメソッドを作ってみる - Qiita

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