私は持っている
class List < ActiveRecord::Base
has_many :list_items
class ListItem < ActiveRecord::Base
belongs_to :list
特定のタイプのすべてのリストを選択してから、関連付けられているすべての list_items を削除したいと考えています。マップやその他のことを試しましたが、行き詰まりました。
List.where('list_type_id=4').?
これはワンライナーである必要があることは知っていますが、?
どうも
** 編集 #1**
SyntaxError: (irb):94: syntax error, unexpected tCONSTANT, expecting ')'
...ListItem.where('list_id = ?' List.where('list_type_id=4').id)....
... ^
(irb):94: syntax error, unexpected ')', expecting $end
...ist.where('list_type_id=4').id).destroy_all
... ^