I have
class List < ActiveRecord::Base
has_many :list_items
class ListItem < ActiveRecord::Base
belongs_to :list
I want to select all lists of a certain type and then delete all the associated list_items. I’ve tried map and some other things but stuck.
List.where('list_type_id=4').?
I know this should be a one-liner but ?
thx
** edit #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
... ^
For posterity,
but yeah, feels like there should be a Railsier way to do it.