使用Rails控制台删除奇数记录

Using the Rails console to delete odd-numbered records

我想使用 Rails 控制台从 Hero table 中删除 ID 为奇数的记录。有人会好心为我建议一种方法吗? 亲切的问候,

瑞安

您可以使用

Hero.where('id MOD(2)!=0').destroy_all