Supprimer définitivement les publications supprimées en masse ?

Eh bien, grâce à @pfaffman, j’ai identifié les publications pertinentes en utilisant ceci :

Post.find_by_sql("select id from posts where topic_id not in (select id from topics)")

J’obtiens ce résultat :

[1] pry(main)> Post.find_by_sql(“select id from posts where topic_id not in (select id from topics)”)
=> [#<Post:0x000055df30d4ee90 id: 150>,
#<Post:0x000055df2e538ff0 id: 51097>,
#<Post:0x000055df2e50ba28 id: 83>,
#<Post:0x000055df2e4ee8b0 id: 40636>,
#<Post:0x000055df2e4a92d8 id: 62562>,
#<Post:0x000055df2e4b7978 id: 13522>,
etc.

Cependant, je n’arrive pas à comprendre comment appliquer destroy_all à cette sélection.

Ceci pourrait aider (pour mon propre bénéfice) :

Des suggestions ?

1 « J'aime »